]> cloudbase.mooo.com Git - ddt180.git/blobdiff - ddt180.z80
Add some comments
[ddt180.git] / ddt180.z80
index cc5ca41c0e34e548f6dbced670e4c399e5f794ea..c4c38a7379e9f3504faef7038818b08ce624bd55 100644 (file)
@@ -14,6 +14,7 @@ TPA   equ     0100h
        .phase  TPA\r
 \r
        jp      start\r
+       ds      3\r
 \r
 ldr_end:\r
 ldr_size       equ     $ - TPA\r
@@ -57,13 +58,17 @@ BDOS_SETDMA equ     26      ;Set DMA Address
 \r
 ; ddtz specific definitions\r
 \r
-STACK_SIZE     equ     64      ;ddtz internal stack\r
+STACK_SIZE     equ     80      ;ddtz internal stack\r
 CONBUF_SIZE    equ     80      ;Size of console input buffer\r
 EXPR_BUF_SIZE  equ     128     ;expressen buffer for conditional breakpoints\r
 BP_CNT         equ     12      ;Number of breakpoints\r
 BP_SIZE                equ     8       ;Size of a breakpoint record\r
 YREG_CNT       equ     10      ;Number of Y registers (0..9)\r
 \r
+SYMCASE_SENS   equ     0       ;Symbols are case sensitive\r
+SYMCASE_CONV   equ     1       ;Convert case when symbols are loaded\r
+SYMCASE_LOWER  equ     2       ;Convert to lower case if set, else to upper case\r
+\r
 ;-------------------------------------------------------------------------------\r
 \r
 ddtz_base:\r
@@ -75,6 +80,14 @@ sub_0004h:
        ret\r
 ddtz_bdos:\r
        jp      0\r
+screen_width:\r
+       db      80\r
+symlen_max:\r
+       db      16\r
+\r
+symattrib:\r
+       db      0\r
+\r
 \r
 current_cseg   defl    $ - current_cseg\r
        .phase  current_phase + current_cseg\r
@@ -122,9 +135,11 @@ reg.pc:    dw      TPA
 var.$: dw      0000h\r
 var.@: dw      0\r
 \r
-error_func:dw  l0146h\r
+error_func:dw  p_msg_error\r
 cmd_rpt:dw     mainloop\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 conbuf:\r
        db      CONBUF_SIZE\r
 \r
@@ -168,6 +183,8 @@ l0093h:
 \r
        ds      CONBUF_SIZE + 3 - ($ - conbuf)\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 CMDTAB:\r
        dw      cmd_@           ;examine/substitute the displacement register @\r
        dw      cmd_A           ;Assemble\r
@@ -199,7 +216,7 @@ CMDTAB:
 \r
 mainloop:\r
        ld sp,stack\r
-       ld hl,l0146h\r
+       ld hl,p_msg_error\r
        ld (error_func),hl\r
        ld hl,(reg.pc)\r
        ld (var.$),hl\r
@@ -236,7 +253,9 @@ exe_hl:
        call CALL_HL\r
        jr mainloop\r
 \r
-l0146h:\r
+;-------------------------------------------------------------------------------\r
+\r
+p_msg_error:\r
        call    pstr_inl\r
        dc      '?'\r
        ;fall thru\r
@@ -392,6 +411,8 @@ p_char_lparen:
 outquote:\r
        ld a,''''\r
 outchar:\r
+       push ix\r
+       push iy\r
        push hl\r
        push de\r
        push bc\r
@@ -406,6 +427,8 @@ outchar:
        pop bc\r
        pop de\r
        pop hl\r
+       pop iy\r
+       pop ix\r
        ret\r
 \r
 pstr:\r
@@ -424,14 +447,29 @@ pstr_inl:
        ex      (sp),hl\r
        ret\r
 \r
-p_fill_space:\r
-       call    outbl\r
+p_align_@_sym:\r
+       push    de\r
+       ld      de,(var.@)\r
+       ld      a,d\r
+       or      e\r
+       pop     de\r
+       ld      a,(symlen_cur)\r
+       jr      z,$+4\r
+       add     a,6\r
+       add     a,c\r
+       ld      c,a\r
+p_goto_col:\r
        ld      a,(con_col)\r
        cp      c\r
-       jr      c,p_fill_space\r
-       ret\r
+       ret     nc\r
+       ret     z\r
+       call    outbl\r
+       jr      p_goto_col\r
+\r
+;-------------------------------------------------------------------------------\r
 \r
 inchar:\r
+       push ix\r
        push hl\r
        push de\r
        push bc\r
@@ -446,6 +484,7 @@ l0284h:
        pop bc\r
        pop de\r
        pop hl\r
+       pop ix\r
        ret\r
 \r
 get_line:\r
@@ -454,67 +493,45 @@ get_line:
        ld c,BDOS_CBUF\r
        call ddtz_bdos\r
        call crlf\r
-       ld de,conbuf+1\r
-       ld a,(de)\r
-       ld b,a\r
-       ld c,0\r
-       inc b\r
-l0162h:\r
-       inc de\r
-       dec b\r
-       jr z,l0194h\r
-       ld a,(de)\r
-       bit 0,c\r
-       call z,toupper\r
-       ld (de),a\r
-       cp ''''\r
-       jr nz,l0162h\r
-       push de\r
-       dec de\r
-       ld a,(de)\r
-       cp ''''\r
-       jr z,l0190h\r
-       dec de\r
-       ld a,(de)\r
-       cp '^'\r
-       jr z,l0184h\r
-       dec de\r
-       ld a,(de)\r
-       cp '^'\r
-       jr nz,l0190h\r
-l0184h:\r
-       inc de\r
-       push bc\r
-       call sub_0303h\r
-       pop bc\r
-       dec de\r
-       ld a,(de)\r
-       cp ''''\r
-       jr z,l0191h\r
-l0190h:\r
-       inc c\r
-l0191h:\r
-       pop de\r
-       jr l0162h\r
-l0194h:\r
-       xor a\r
-       ld (de),a\r
-       ld de,conbuf+2\r
+       ld hl,conbuf+1\r
+       ld      e,(hl)\r
+       xor     a\r
+       ld      d,a\r
+       inc     hl\r
+       ex      de,hl\r
+       add     hl,de\r
+       ld      (hl),a\r
        pop hl\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
+get_char_upper:\r
+       ld a,(de)\r
 toupper:\r
        cp 'a'\r
        ret c\r
        cp 'z'+1\r
-       ret nc\r
+       ccf\r
+       ret c\r
        and 05fh\r
        ret\r
 \r
+tolower:\r
+       cp 'A'\r
+       ret c\r
+       cp 'Z'+1\r
+       ccf\r
+       ret c\r
+       or 020h\r
+       ret\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
 skipbl0:\r
        inc de\r
 skipbl:\r
-       ld a,(de)\r
+       call get_char_upper\r
        call test_whitespace\r
        jr z,skipbl0\r
        or a\r
@@ -535,18 +552,22 @@ assert_eol:
 to_error:\r
        jp ERROR\r
 \r
-chk_sp:\r
+;-------------------------------------------------------------------------------\r
+\r
+chk_stack:\r
        push hl\r
        push de\r
        ld hl,0\r
        add hl,sp\r
-       ld de,stack-40\r
+       ld de,stack-(STACK_SIZE-28)\r
        call cp_hl_de\r
        pop de\r
        pop hl\r
        jr c,to_error\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 add_hl_a:\r
        add a,l\r
        ld l,a\r
@@ -571,6 +592,8 @@ sub_hl_a:
        pop     bc\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 sym_getname:\r
        push    de\r
        push    hl\r
@@ -608,45 +631,15 @@ pss_l:
        pop     bc\r
        ret\r
 \r
-p_sym_space:\r
+p_symbol:\r
   if 0\r
        ld      a,(dash_flag)\r
        or      a\r
        ret     nz\r
   endif\r
-\r
        push    hl\r
-       push    bc\r
-       ld      c,a\r
-       ld      a,(con_col)\r
-       ld      b,a\r
        call    sym_getname\r
-       jr      z,psb_align\r
-       bit     7,c\r
-       jr      z,psb_nd\r
-       call    pstr_inl\r
-       dc      ' .'\r
-psb_nd:\r
-       call    p_symstr\r
-\r
-psb_align:\r
-       ld      a,(con_col)\r
-       sub     b\r
-       ld      b,a\r
-       ld      a,(symlen_max)\r
-       bit     7,c\r
-       jr      z,$+4\r
-       add     a,2\r
-       res     7,c\r
-       add     c\r
-       sub     b\r
-       ld      b,a\r
-       jr      z,psb_e\r
-psb_a_l:\r
-       call    outbl\r
-       djnz    psb_a_l\r
-psb_e:\r
-       pop     bc\r
+       call    nz,p_symstr\r
        pop     hl\r
        ret\r
 \r
@@ -667,13 +660,15 @@ pl_e:
        pop     hl\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 lookupch:\r
        ld b,0\r
 l02f5h:\r
        ld a,(hl)\r
        and a\r
        ret z\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp (hl)\r
        jr z,l0300h\r
        inc hl\r
@@ -704,12 +699,12 @@ l030ch:
 sub_0318h:\r
        push bc\r
        res 7,b\r
-       defb 03eh\r
+       defb 03eh               ;ld a,nn\r
 sub_031ch:\r
        push bc\r
        push de\r
 l031eh:\r
-       ld a,(de)\r
+       call get_char_upper\r
        xor (hl)\r
        and 07fh\r
        jr nz,l0336h\r
@@ -824,14 +819,14 @@ get_range:
        inc de\r
 l03a2h:\r
        push hl\r
-       push af\r
+       push af                 ;'S' flag\r
        call expr\r
        jr c,l03b8h\r
        ld b,h\r
        ld c,l\r
        pop af\r
        pop hl\r
-       jr z,l03b6h\r
+       jr z,l03b6h             ;'S'?\r
        ld a,c\r
        sub l\r
        ld c,a\r
@@ -845,10 +840,12 @@ l03b6h:
 l03b8h:\r
        pop af\r
        pop hl\r
-       jr z,error0\r
+       jr z,error0             ;'S', but no expression following\r
        scf\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 expr:\r
        call skipbl\r
 expr1:\r
@@ -868,6 +865,8 @@ expr1:
        pop de\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 do_op_eq:\r
        jr z,l03edh\r
        jr l03ech\r
@@ -1097,13 +1096,15 @@ tblf_opa:
        dw      doop_xor\r
        dw      0\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 fact_factor:\r
        call do_factor\r
        ret nc\r
        jp ERROR\r
 \r
 do_factor:\r
-       call chk_sp\r
+       call chk_stack\r
        call get.number\r
        ret nc\r
        inc de\r
@@ -1125,6 +1126,9 @@ do_factor:
        ld hl,(var.$)\r
        cp '$'\r
        ret z\r
+       ld hl,ddtz_base\r
+       cp 'Z'\r
+       ret z\r
        cp '-'\r
        jr z,fact_factneg\r
        cp '~'\r
@@ -1147,6 +1151,8 @@ do_factor:
        scf\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 fact_reg.Y:\r
        call get.decdigit\r
        jr c,error1\r
@@ -1249,6 +1255,11 @@ error1:
 fact_symbol:\r
        push    bc\r
        ld      hl,ddtz_base            ;symtbl start\r
+       ld      a,(symattrib)\r
+       ld      c,07fh\r
+       rra\r
+       jr      c,fs_nxtsym\r
+       res     5,c\r
 \r
 fs_nxtsym:\r
        ld      a,(hl)                  ;symlen\r
@@ -1258,12 +1269,17 @@ fs_nxtsym:
        inc     b\r
        push    hl                      ;symtbl ptr\r
        push    de                      ;inpsym ptr\r
-fs_2:\r
+fs_nxtchar:\r
        ld      a,(de)\r
        djnz    fs_3\r
        call    test_sym_char\r
        jr      z,fs_cont\r
        pop     hl                      ;inpsym ptr (discard)\r
+       inc     de\r
+       cp      a,':'\r
+       jr      z,fs_cont_1\r
+       dec     de\r
+\r
        pop     hl                      ;symtbl ptr\r
        inc     hl\r
        ld      a,(hl)                  ;symval h\r
@@ -1273,19 +1289,24 @@ fs_2:
        or      a                       ;clear carry\r
        pop     bc\r
        ret\r
+\r
 fs_3:\r
        inc     de\r
        dec     hl\r
-       cp      (hl)\r
-       jr      z,fs_2\r
+       xor     (hl)\r
+       and     c\r
+       jr      z,fs_nxtchar\r
 fs_cont:                               ;start over\r
        pop     de                      ;inpsym ptr\r
+fs_cont_1:\r
        pop     hl                      ;symtbl ptr\r
        ld      a,(hl)\r
        add     a,3\r
        call    sub_hl_a\r
        jr      fs_nxtsym\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 get.number:\r
        call get.hexdigit\r
        ret c\r
@@ -1329,7 +1350,7 @@ l05dbh:
        jr next_bindigit\r
 l05e4h:\r
        cp '"'\r
-       jp nz,ERROR\r
+       jr nz,error11\r
        call get.bindigit\r
        jr nc,l05dbh\r
        or a\r
@@ -1354,16 +1375,18 @@ next_decdigit:
 decnum_done:\r
        cp '.'\r
        ret z\r
+error11:\r
        jp ERROR\r
 \r
 sub_060ch:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '['\r
        jr l0614h\r
 \r
 get.hexdigit:\r
        ld a,(de)\r
 hex_digit:\r
+       call toupper\r
        cp 'F'+1\r
 l0614h:\r
        ccf\r
@@ -1374,13 +1397,13 @@ l0614h:
        ret\r
 \r
 get.decdigit:\r
-       ld a,(de)\r
+       call get_char_upper\r
 l061eh:\r
        cp '9'+1\r
        jr l0625h\r
 \r
 get.bindigit:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '1'+1\r
 l0625h:\r
        ccf\r
@@ -1390,6 +1413,8 @@ l0625h:
        sub '0'\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 p_cpustat0:\r
        call assert_eol\r
 p_cpustat:\r
@@ -1417,7 +1442,6 @@ l065bh:
        djnz l065bh\r
        pop af\r
        pop hl\r
-       and a\r
        call nz,outbl6\r
        call nz,p_offset\r
        jp crlf\r
@@ -1537,6 +1561,10 @@ b_0709_start:
        db      000h\r
        db      000h\r
 \r
+;-------------------------------------------------------------------------------\r
+; > G [startaddr] [;breakp..]\r
+;      Go [to start] [with temporary breakpoints]\r
+\r
 cmd_G:\r
        sub a\r
        ld (trace_call_flag),a\r
@@ -1554,19 +1582,51 @@ l0740h:
        call bp_enter\r
        jp user_go\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
+bpl_init:\r
+       ld      b,BP_CNT\r
+       ld      ix,bp_tab\r
+       ex      (sp),hl\r
+       ld      (pbl_loop_adr),hl\r
+       ex      (sp),hl\r
+       ret\r
+\r
+bpl_next:\r
+       ld      de,BP_SIZE\r
+       add     ix,de\r
+       dec     b\r
+       ret     z\r
+\r
+       ex      (sp),hl\r
+       ld      hl,(pbl_loop_adr)\r
+       ex      (sp),hl\r
+       ret\r
+\r
 bp_clr_temporary:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l075ah:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 0f1h\r
        ld (ix+000h),a\r
        call bp_clr_condition\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l075ah\r
+\r
+       call bpl_next\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > B\r
+;      display all breakpoints\r
+; > B breakp [breakp..]\r
+;      set breakpoints\r
+; > BX\r
+;      clear all breakpoints\r
+; > BX address [address..]\r
+;      clear breakpoints\r
+;\r
+; where breakp is:\r
+;      [R] expression [I condition]\r
+\r
 cmd_B:\r
        call skipbl\r
        jr z,bp_print\r
@@ -1591,9 +1651,8 @@ bp_clr_next:
 bp_clr_all:\r
        scf\r
 bp_clr:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l0799h:\r
+       call    bpl_init\r
+\r
        push af\r
        jr c,l07a7h\r
        ld e,(ix+002h)\r
@@ -1604,16 +1663,13 @@ l07a7h:
        ld (ix+000h),000h\r
        call bp_clr_condition\r
 l07aeh:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
        pop af\r
-       djnz l0799h\r
+       call bpl_next\r
        ret\r
 \r
 bp_print:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-bp_pr_l:\r
+       call    bpl_init\r
+\r
        bit 0,(ix+000h)\r
        jr z,bp_pr_cont\r
        ld a,'R'\r
@@ -1626,8 +1682,10 @@ l07cdh:
        ld l,(ix+002h)\r
        ld h,(ix+003h)\r
        call out.hl.@\r
-       ld a,82h\r
-       call p_sym_space\r
+       call    outbl\r
+       call    p_symbol\r
+       ld      c,9\r
+       call    p_align_@_sym\r
        call    pstr_inl\r
        dc      ':'\r
        ld l,(ix+004h)\r
@@ -1645,11 +1703,10 @@ l07cdh:
 l0805h:\r
        call crlf\r
 bp_pr_cont:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz bp_pr_l\r
+       call bpl_next\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
 ; Add break points to list\r
 ;   A = 1       Permanent (B command)\r
 ;   A = 2       Temporary (G command)\r
@@ -1665,7 +1722,7 @@ bp_enter:
 bp_e_1:\r
        push bc\r
        call expr\r
-       jp c,ERROR\r
+       jr c,error12\r
        pop bc\r
        bit 0,b\r
        push bc\r
@@ -1690,17 +1747,14 @@ bp_e_1:
        jr bp_enter\r
 \r
 bp_get_freeslot:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-bp_gf_l:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 00fh\r
        ret z\r
-       push bc\r
-       ld bc,BP_SIZE\r
-       add ix,bc\r
-       pop bc\r
-       djnz bp_gf_l\r
+\r
+       call    bpl_next\r
+error12\r
        jp ERROR\r
 \r
 bp_get_count:\r
@@ -1710,7 +1764,7 @@ bp_get_count:
        ret nz\r
        inc de\r
        call expr\r
-       jp c,ERROR\r
+       jr c,error12\r
        ret\r
 \r
 bp_get_condition:\r
@@ -1722,7 +1776,7 @@ bp_get_condition:
        call skipbl\r
        push de\r
        call expr\r
-       jp c,ERROR\r
+       jr c,error12\r
        ex de,hl\r
        pop de\r
        push de\r
@@ -1734,7 +1788,7 @@ bp_get_condition:
        add hl,bc\r
        ld de,expr_bufe\r
        call cp_hl_de\r
-       jp nc,ERROR\r
+       jr nc,error12\r
        pop hl\r
        ld (expr_p2),hl\r
        pop de\r
@@ -1748,6 +1802,8 @@ bp_get_condition:
        ld hl,(expr_p2)\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 bpddtz:\r
        ld (reg.l),hl\r
        pop hl\r
@@ -1802,9 +1858,8 @@ sub_0913h:
        ex af,af'\r
        sub a\r
        ld (l0941h),a\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l0920h:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 007h\r
        jr z,l0938h\r
@@ -1816,9 +1871,8 @@ l0920h:
        call z,sub_0942h\r
        pop bc\r
 l0938h:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l0920h\r
+\r
+       call    bpl_next\r
        ex af,af'\r
        ret\r
 \r
@@ -1856,9 +1910,8 @@ l0974h:
        ret\r
 \r
 sub_097ah:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l0980h:\r
+       call    bpl_init\r
+\r
        bit 5,(ix+000h)\r
        res 5,(ix+000h)\r
        jr z,l099ah\r
@@ -1871,15 +1924,13 @@ l0980h:
        ld (hl),a\r
 l099ah:\r
        res 3,(ix+000h)\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l0980h\r
+\r
+       call    bpl_next\r
        ret\r
 \r
 sub_09a6h:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l09ach:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and 003h\r
        jr z,l09c0h\r
@@ -1889,9 +1940,8 @@ l09ach:
        call cp_hl_de\r
        ret z\r
 l09c0h:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l09ach\r
+\r
+       call    bpl_next\r
        sub a\r
        inc a\r
        ret\r
@@ -1908,15 +1958,14 @@ sub_09cah:
        and a\r
        ld a,008h\r
        jr nz,l09edh\r
-       ld a,004h\r
+       rra\r
 l09edh:\r
        ld (ix+000h),a\r
        ret\r
 \r
-sub_09f1h:\r
-       ld b,BP_CNT\r
-       ld ix,bp_tab\r
-l09f7h:\r
+bp_set_to_mem:\r
+       call    bpl_init\r
+\r
        ld a,(ix+000h)\r
        and c\r
        jr z,l0a1dh\r
@@ -1937,11 +1986,12 @@ l09f7h:
        inc hl\r
        ld (hl),d\r
 l0a1dh:\r
-       ld de,BP_SIZE\r
-       add ix,de\r
-       djnz l09f7h\r
+\r
+       call    bpl_next\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 user_go:\r
        sub a\r
        ld (b_21e2_start),a\r
@@ -1956,7 +2006,7 @@ user_go:
        call sub_1ffeh\r
        ld c,008h\r
 l0a41h:\r
-       call sub_09f1h\r
+       call bp_set_to_mem\r
        ld sp,reg.l2\r
        pop hl\r
        pop de\r
@@ -1975,6 +2025,8 @@ l0a41h:
        ld sp,(reg_sp)\r
        jp reg.iff\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 bp_clr_condition:\r
        ld a,(ix+000h)\r
        and 003h\r
@@ -2027,6 +2079,12 @@ l0ab0h:
        ld (iy+007h),d\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > Y\r
+;      examine all Y variables\r
+; > Y[0..9]\r
+;      examine (and substitute) an Y variable\r
+\r
 cmd_Y:\r
        call get.decdigit\r
        jr c,l0bc3h\r
@@ -2042,16 +2100,20 @@ l0bc3h:
 l0bc7h:\r
        push af\r
        call sub_0bdch\r
+       call    outbl\r
        pop af\r
        push af\r
        call get_y_val\r
-       ld a,82h\r
-       call p_sym_space\r
+       call p_symbol\r
        pop af\r
        inc a\r
-       bit 0,a\r
        push af\r
-       call z,crlf\r
+       rra\r
+       push    af\r
+       ld      c,11\r
+       call    c,p_align_@_sym\r
+       pop     af\r
+       call    nc,crlf\r
        pop af\r
        cp YREG_CNT\r
        jr c,l0bc7h\r
@@ -2071,6 +2133,14 @@ sub_0bdch:
        ld c,003h\r
        jp l0c33h\r
 \r
+;-------------------------------------------------------------------------------\r
+; > X\r
+;      eXamine (display) all cpu registers and\r
+;      the instruction at the current program counter\r
+; > X register\r
+;      eXamine (and substitute) a register\r
+\r
+\r
 cmd_X:\r
        call skipbl\r
        call sub_0caeh\r
@@ -2096,15 +2166,14 @@ l0c15h:
        call skipbl\r
        jr z,l0c30h\r
        call sub_0363h\r
-       ld b,h\r
-       ld c,l\r
-       pop af\r
+       ex de,hl\r
+       pop bc\r
        pop hl\r
-       ld (hl),c\r
-       bit 0,a\r
+       ld (hl),e\r
+       bit 0,c\r
        ret z\r
        inc hl\r
-       ld (hl),b\r
+       ld (hl),d\r
        ret\r
 l0c30h:\r
        pop af\r
@@ -2112,19 +2181,18 @@ l0c30h:
        ret\r
 \r
 l0c33h:\r
-       ld b,c\r
        call pstr\r
        call    pstr_inl\r
        dc      '='\r
        ld a,(de)\r
-       bit 0,b\r
+       bit 0,c\r
        jp z,out_hex\r
        ld l,a\r
        inc de\r
        ld a,(de)\r
        dec de\r
        ld h,a\r
-       bit 1,b\r
+       bit 1,c\r
        jp z,out_hl\r
        jp out.hl.@\r
 \r
@@ -2302,6 +2370,10 @@ b_0cfa_start:
        db      000h\r
        dw      reg.f\r
 \r
+;-------------------------------------------------------------------------------\r
+; > S [startaddr]\r
+;      Substitute memory\r
+\r
 cmd_S:\r
        ld hl,(last_S)\r
        call get_lastarg_def\r
@@ -2319,10 +2391,16 @@ l0d60h:
        dec hl\r
        inc de\r
        cp '.'\r
+       jr      nz,cmds_dash\r
+       call get_char_upper\r
+       or      a\r
+       jr      nz,l0d8ah\r
+       ret\r
+cmds_dash:\r
        jp z,assert_eol\r
        cp '-'\r
        jr nz,l0d8ah\r
-       ld a,(de)\r
+       call get_char_upper\r
        or a\r
        dec hl\r
        jr z,l0d60h\r
@@ -2332,6 +2410,10 @@ l0d8ah:
        call sub_0ef8h\r
        jr l0d60h\r
 \r
+;-------------------------------------------------------------------------------\r
+; > @\r
+;      examine (substitute) displacement register @\r
+\r
 cmd_@:\r
        call assert_eol\r
        ld hl,msg_@\r
@@ -2342,6 +2424,10 @@ cmd_@:
 msg_@:\r
        dc      '@'\r
 \r
+;-------------------------------------------------------------------------------\r
+; >>I [port]\r
+;      Input a byte from port\r
+\r
 cmd_I:\r
        ld hl,cmd_I\r
        ld (cmd_rpt),hl\r
@@ -2358,6 +2444,10 @@ cmd_I:
        call out.bin.b\r
        jp crlf\r
 \r
+;-------------------------------------------------------------------------------\r
+; >>O [byte] [port]\r
+;      Output a byte to a port\r
+\r
 cmd_O:\r
        ld hl,cmd_O\r
        ld (cmd_rpt),hl\r
@@ -2376,6 +2466,10 @@ cmd_O:
        out (c),a\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > Vstartaddr endaddr targetaddr\r
+;      Verify (compare) two memory areas\r
+\r
 cmd_V:\r
        call sub_034eh\r
 l0dedh:\r
@@ -2407,8 +2501,12 @@ l0e10h:
        jr nz,l0dedh\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > M[V] startaddr endaddr destaddr\r
+;      Move memory [and verify]\r
+\r
 cmd_M:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'V'\r
        jr nz,l0e1fh\r
        inc de\r
@@ -2437,10 +2535,21 @@ cmdm_up:
        jr z,l0dedh\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > H\r
+;      display Highest load address of last filed loaded, Maximum "High"\r
+;      off all loaded files, and Top address of available memory\r
+; > HS\r
+;      display symbol list\r
+; > H expression\r
+;      evaluate expression and display result in hex, decimal and other formats\r
+; > H expression expression\r
+;      display sum und difference of expressions\r
+\r
 cmd_H:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'S'\r
-       jr z,p_symbols\r
+       jr z,p_sym_list\r
 \r
        call expr\r
        jp c,p_max_high0\r
@@ -2474,14 +2583,14 @@ l0e5eh:
        call outbl\r
        ld a,l\r
        call out.ascii\r
-       ld a,80h\r
-       call p_sym_space\r
+       call    outbl2\r
+       call p_symbol\r
        jp crlf\r
 \r
-p_symbols:\r
+p_sym_list:\r
        inc     de\r
        call    assert_eol\r
-       ld      a,(symlen_max)\r
+       ld      a,(symlen_cur)\r
        add     a,7\r
        ld      b,a\r
        ld      c,0\r
@@ -2495,6 +2604,7 @@ psym_nxtsym:
        cp      0c3h\r
        jr      z,psym_e\r
 \r
+       call    p_goto_col\r
        ex      de,hl\r
        call    out_hl\r
        call    outbl\r
@@ -2504,16 +2614,13 @@ psym_nxtsym:
        ld      a,c\r
        add     b\r
        ld      c,a\r
-       ld      a,80                    ;screen width\r
+       ld      a,(screen_width)\r
        sub     b\r
        cp      c\r
-       jr      c,psym_nxtline\r
-       call    p_fill_space\r
-       jr      psym_nxtsym\r
+       jr      nc,psym_nxtsym\r
 \r
-psym_nxtline:\r
-       ld      c,0\r
        call    crlf\r
+       ld      c,0\r
        jr      psym_nxtsym\r
 \r
 psym_e:\r
@@ -2523,8 +2630,12 @@ psym_e:
        jp      crlf\r
 \r
 \r
+;-------------------------------------------------------------------------------\r
+; > Q[J] startaddr endaddr bytes\r
+;      Query memory for a byte string [Justified]\r
+\r
 cmd_Q:\r
-       ld a,(de)\r
+       call get_char_upper\r
        sub 'J'\r
        ld (cmd_Q_jopt),a\r
        jr nz,l0e8dh\r
@@ -2562,6 +2673,10 @@ l0eb0h:
        pop bc\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > Z startaddr endaddr bytes\r
+;      Zap (fill) memory with a byte string\r
+\r
 cmd_Z:\r
        call get_arg_range\r
        push bc\r
@@ -2675,6 +2790,10 @@ l0f42h:
        ld (last_S),hl\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; >>D [startaddr] [endaddr]\r
+;      Display memory in hex and ASCII\r
+\r
 cmd_D:\r
        ld hl,cmd_D\r
        ld (cmd_rpt),hl\r
@@ -2743,13 +2862,17 @@ l0fach:
        ld a,'.'\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > Fcommandline\r
+;      specifiy filenames and command line\r
+\r
 cmd_F:\r
        push de\r
        ld hl,DMA_BUF+1\r
        ld (hl),' '\r
        inc hl\r
 l0fb6h:\r
-       ld a,(de)\r
+       call get_char_upper\r
        ld (hl),a\r
        inc hl\r
        inc de\r
@@ -2840,6 +2963,7 @@ sub_1012h:
        cp '.'\r
        ret z\r
        ld c,'?'\r
+       call toupper\r
        cp '*'\r
        ret\r
 \r
@@ -2871,6 +2995,8 @@ sub_1043h:
        cp ','\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 setup_fcb:\r
        push de\r
        ld hl,12\r
@@ -2887,6 +3013,8 @@ l1052h:
        pop de\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 file_open:\r
        ld (cur_fcb),de\r
        call setup_fcb\r
@@ -3010,6 +3138,10 @@ read_hexbyte0:
        pop     bc\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; > R [displacement]\r
+;      Read a binary or hex file and or symbol file [add displacement]\r
+\r
 cmd_R:\r
        ld hl,0\r
        call get_lastarg_def\r
@@ -3096,8 +3228,10 @@ read_symfile:
        call pstr_inl\r
        db      'SYMBOLS',CR,LF+80h\r
 \r
-       dec de\r
-       call file_open\r
+       dec     de\r
+       call    file_open\r
+       ld      a,(symattrib)\r
+       ld      c,a\r
 rs_1:\r
        call    read_byte\r
 rs_2:\r
@@ -3129,11 +3263,17 @@ rs_5:
        call    read_byte       ; next char of symbol name\r
        call    test_sym_char   ; valid char?\r
        jr      nz,rs_6\r
+       bit     SYMCASE_CONV,c\r
+       jr      z,rs_51\r
+       call    toupper\r
+       bit     SYMCASE_LOWER,c\r
+       call    nz,tolower\r
+rs_51:\r
        ld      (hl),a          ;\r
        inc     b               ; symlen++\r
-       ld      a,b             ;\r
-       cp      10h+1           ;\r
-       jr      c,rs_5          ;\r
+       ld      a,(symlen_max)  ;\r
+       cp      b               ;\r
+       jr      nc,rs_5         ;\r
 error3:\r
        jp      ERROR           ;\r
 \r
@@ -3166,14 +3306,15 @@ rs_61:
        ld      de,(BDOS+1)     ;\r
        ld      (BDOS+1),hl     ;\r
        ex      de,hl           ;\r
-       pop     af              ; symlen\r
-       ld      (hl),a          ;\r
+       pop     bc              ; symlen\r
+       ld      (hl),b          ;\r
        inc     hl              ;\r
        pop     de              ; symval\r
        ld      (hl),e          ;\r
        inc     hl              ;\r
        ld      (hl),d          ;\r
-       ld      hl,symlen_max   ;\r
+       ld      a,b             ;\r
+       ld      hl,symlen_cur   ;\r
        cp      (hl)            ; new max?\r
        jr      c,$+3           ;\r
        ld      (hl),a          ;\r
@@ -3203,18 +3344,21 @@ test_sym_char:
 ; return nc if valid alfanumeric char\r
 \r
 test_alphanum:\r
-       cp      'z'+1\r
+       cp      'z'\r
+       ret     z\r
        ccf\r
        ret     c\r
        cp      'a'\r
        ret     nc\r
-       cp      'Z'+1\r
+       cp      'Z'\r
+       ret     z\r
        ccf\r
        ret     c\r
        cp      '?'\r
        ret     nc\r
 test_numeral:\r
-       cp      '9'+1\r
+       cp      '9'\r
+       ret     z\r
        ccf\r
        ret     c\r
        cp      '0'\r
@@ -3231,6 +3375,8 @@ test_whitespace:
        cp      TAB\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 p_max_high0:\r
        call assert_eol\r
 p_max_high:\r
@@ -3248,6 +3394,10 @@ p_max_high:
        call out_hl\r
        jp crlf\r
 \r
+;-------------------------------------------------------------------------------\r
+; > Wstartaddr endaddr\r
+;      Write a file to disk\r
+\r
 cmd_W:\r
        call get_arg_range\r
        call assert_eol\r
@@ -3309,59 +3459,61 @@ close_file:
        ld c,BDOS_CLOSE\r
        jp ddtz_bdos\r
 \r
+;-------------------------------------------------------------------------------\r
+; > A [startaddr]\r
+;      Assemble Zilog Z180 mnemonics\r
+\r
 cmd_A:\r
        ld hl,(last_A)\r
        call get_lastarg_def\r
-       push hl\r
-       pop iy\r
-       ld hl,l1259h\r
+       ld (last_A),hl\r
+       ld (cmd_A_prev),hl\r
+       ld hl,cmda_restart\r
        ld (error_func),hl\r
        ld (l1262h),sp\r
-l1211h:\r
-       push iy\r
-       pop hl\r
-       ld (last_A),hl\r
+cmda_loop:\r
+       ld hl,(last_A)\r
        ld (var.$),hl\r
        push hl\r
        call p_disas_line\r
-       pop iy\r
-       ld de,(var.@)\r
-       ld a,d\r
-       or e\r
-       ld c,17\r
-       jr z,l122dh\r
-       ld c,25\r
-l122dh:\r
-       call p_fill_space\r
+       ld c,19\r
+       call p_align_@_sym\r
        ld c,b\r
        push bc\r
        call get_line\r
        pop bc\r
+       pop hl\r
        call skipbl\r
        cp '.'\r
        ret z\r
        cp '-'\r
        jr nz,l124bh\r
-       ld iy,(cmd_A_prev)\r
-       jr l1211h\r
+       ld hl,(cmd_A_prev)\r
+       jr cmda_lpend\r
 l124bh:\r
+       push hl\r
+       pop iy\r
+       push hl\r
        and a\r
-       call nz,sub_1268h\r
-       ld (cmd_A_prev),iy\r
+       call nz,asemble_line\r
        ld b,0\r
-       add iy,bc\r
-       jr l1211h\r
+       pop hl\r
+       ld (cmd_A_prev),hl\r
+       add hl,bc\r
+cmda_lpend:\r
+       ld (last_A),hl\r
+       jr cmda_loop\r
 \r
-l1259h:\r
-       call l0146h\r
+cmda_restart:\r
+       call p_msg_error\r
        ld sp,(l1262h)\r
-       jr l1211h\r
+       jr cmda_loop\r
 \r
-sub_1268h:\r
+asemble_line:\r
        call skipbl\r
        ld hl,t_MNEMONICS\r
        call sub_030ah\r
-       jp nc,ERROR\r
+       jr nc,error4\r
        call skipbl\r
        push de\r
        ld a,b\r
@@ -3380,6 +3532,8 @@ sub_1268h:
 CALL_HL:\r
        jp (hl)\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 b_1289_start:\r
        dw      as.ADC_SBC              ;ADC\r
        db      088h                    ;\r
@@ -3537,6 +3691,8 @@ b_1289_start:
        dw      as.TSTIO                ;TSTIO\r
        db      074h                    ;\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 as.TST:\r
        call arg.r_HL_A         ;\r
        jr nc,as.tst_0\r
@@ -3606,13 +3762,13 @@ as.LD:
        jp c,l149ch\r
        call arg.IX_IY\r
        jp c,l14f5h\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'I'\r
        jp z,l1511h\r
        cp 'R'\r
        jp z,l1519h\r
        cp '('\r
-       jp nz,ERROR\r
+       jr nz,error5\r
        inc de\r
        call arg.ww\r
        jp c,l1528h\r
@@ -3634,12 +3790,14 @@ l139bh:
        ld (iy+003h),h\r
        ld c,004h\r
        ret\r
+\r
 l13aah:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'A'\r
-       jp nz,ERROR\r
+       jr nz,error5\r
        inc de\r
        ld b,032h\r
+\r
 as.store_3:\r
        call assert_eol\r
        ld (iy+000h),b\r
@@ -3647,6 +3805,7 @@ as.store_3:
        ld (iy+002h),h\r
        ld c,003h\r
        ret\r
+\r
 l13c2h:\r
        cp 020h\r
        jr z,l13d0h\r
@@ -3659,6 +3818,7 @@ l13c9h:
 l13d0h:\r
        ld b,022h\r
        jr as.store_3\r
+\r
 l13d4h:\r
        ld b,a\r
        call assert_comma\r
@@ -3674,10 +3834,11 @@ l13d4h:
        add a,b\r
        add a,040h\r
        cp 076h\r
-       jp z,ERROR\r
+       jr z,error60\r
 l13ech:\r
        ld b,a\r
        jp as.opc.noarg\r
+\r
 l13f0h:\r
        call arg.IDX_displcmnt\r
        jr nc,l1413h\r
@@ -3687,7 +3848,7 @@ l13f0h:
        rlca\r
        add a,046h\r
        cp 076h\r
-       jp z,ERROR\r
+       jr z,error60\r
 \r
 l1400h:\r
        ld b,a\r
@@ -3698,21 +3859,23 @@ l1400h:
        ld (iy+000h),a\r
        ld c,003h\r
        ret\r
+\r
 l1413h:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'I'\r
        jr z,l1426h\r
        cp 'R'\r
        jr nz,l1432h\r
        ld a,b\r
        cp 007h\r
-       jp nz,ERROR\r
+       jr nz,error60\r
        ld b,05fh\r
        jr l142eh\r
+\r
 l1426h:\r
        ld a,b\r
        cp 007h\r
-       jp nz,ERROR\r
+       jr nz,error60\r
        ld b,057h\r
 l142eh:\r
        inc de\r
@@ -3738,15 +3901,19 @@ l144ch:
        inc de\r
        ld a,b\r
        cp 007h\r
-       jp nz,ERROR\r
+       jr nz,error60\r
        call arg.ww\r
        jr nc,l1466h\r
        cp 030h\r
-       jp nc,ERROR\r
+       jr nc,error60\r
        add a,00ah\r
        ld b,a\r
        call test_paren_close\r
        jp as.opc.noarg\r
+\r
+error60:\r
+       jp error\r
+\r
 l1466h:\r
        call test_expr\r
        call test_paren_close\r
@@ -3758,7 +3925,7 @@ l1471h:
        call arg.r_HL_A\r
        jr nc,l1483h\r
        cp 006h\r
-       jp z,ERROR\r
+       jr z,error60\r
        add a,070h\r
        jp l1400h\r
 \r
@@ -3791,14 +3958,16 @@ l14b4h:
        ld (iy+001h),b\r
        ld c,002h\r
        ret\r
+\r
 l14c3h:\r
        ld a,b\r
        cp 030h\r
        jr nz,error6\r
        ld b,0f9h\r
        jr as.opc.noarg ;14ca\r
+\r
 l14cch:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '('\r
        jr nz,l14e8h\r
        inc de\r
@@ -3810,9 +3979,11 @@ l14cch:
        add a,04bh\r
        ld b,a\r
        jp l13c9h\r
+\r
 l14e3h:\r
        ld b,02ah\r
        jp as.store_3\r
+\r
 l14e8h:\r
        call test_expr\r
        call assert_eol\r
@@ -3822,7 +3993,7 @@ l14e8h:
        jp as.store_3\r
 l14f5h:\r
        call assert_comma\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '('\r
        jr nz,l1509h\r
        inc de\r
@@ -3830,21 +4001,24 @@ l14f5h:
        call test_paren_close\r
        ld b,02ah\r
        jp l1395h\r
+\r
 l1509h:\r
        call test_expr\r
        ld b,021h\r
        jp l1395h\r
+\r
 l1511h:\r
        inc de\r
        call assert_comma\r
        ld b,047h\r
        jr l151fh\r
+\r
 l1519h:\r
        inc de\r
        call assert_comma\r
        ld b,04fh\r
 l151fh:\r
-       ld a,(de)\r
+       call get_char_upper\r
        inc de\r
        cp 'A'\r
        jr z,gen.opc.ED2\r
@@ -3858,7 +4032,7 @@ l1528h:
        ld b,a\r
        call test_paren_close\r
        call assert_comma\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'A'\r
        jr nz,error6\r
        inc de\r
@@ -3881,7 +4055,7 @@ as.ADC_SBC:
        jr nc,as.AND_CP_OR_SUB_XOR\r
        call assert_comma\r
        call arg.ww\r
-       jp nc,ERROR\r
+       jr nc,error6\r
        push af\r
        ld a,b\r
        cp 088h\r
@@ -3894,6 +4068,7 @@ l156ch:
 l156eh:\r
        ld b,a\r
        jr gen.opc.ED2\r
+\r
 as.ADD:\r
        ld hl,t_HL.AF\r
        call sub_0318h\r
@@ -3908,7 +4083,7 @@ as.ADD:
        ld hl,t_BC.DE.IY.SP\r
 l158eh:\r
        call arg.reg_16bit\r
-       jp nc,ERROR\r
+       jr nc,error6\r
        add a,009h\r
 l1596h:\r
        ld b,a\r
@@ -3916,11 +4091,12 @@ l1596h:
 l159ah:\r
        call assert_comma\r
        call arg.ww\r
-       jp nc,ERROR\r
+error61nc:\r
+       jr nc,error6\r
        add a,009h\r
        jp l13ech\r
 as.AND_CP_OR_SUB_XOR:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'A'\r
        jr nz,l15b8h\r
        push de\r
@@ -3952,7 +4128,7 @@ as.SHIFTOP:
        call arg.r_HL_A\r
        jr c,l15fah\r
        call arg.IDX_displcmnt\r
-       jp nc,ERROR\r
+       jr nc,error61nc\r
        ld a,b\r
        add a,006h\r
        ld b,a\r
@@ -3982,7 +4158,7 @@ as.BITOP:
        call arg.r_HL_A\r
        jr c,l1624h\r
        call arg.IDX_displcmnt\r
-       jp nc,ERROR\r
+       jr nc,error61nc\r
        ld a,l\r
        rlca\r
        rlca\r
@@ -4182,7 +4358,7 @@ l1739h:
 as.EX:\r
        ld hl,b_176d_start\r
        call sub_030ah\r
-       jp nc,ERROR\r
+       jr nc,error7\r
        ld c,b\r
        call assert_eol\r
        ld b,000h\r
@@ -4223,7 +4399,7 @@ as.DEC_INC:
        call arg.r_HL_A\r
        jr c,l17cch\r
        call arg.IDX_displcmnt\r
-       jp nc,ERROR\r
+       jr nc,error8\r
        ld a,b\r
        add a,030h\r
        jp l1400h\r
@@ -4278,7 +4454,7 @@ arg.j_displ:
        ret\r
 \r
 arg.addr_8bit:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '('\r
        jr nz,arg.imm_8bit\r
        inc de\r
@@ -4362,7 +4538,7 @@ l1852h:
 arg.IDX_displcmnt:\r
        push hl\r
        push bc\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '('\r
        jr nz,l18a1h\r
        push de\r
@@ -4377,14 +4553,14 @@ arg.IDX_displcmnt:
        ld a,0fdh\r
 l186eh:\r
        ld (prefix_ixiy),a\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp '+'\r
        jr z,l1882h\r
        cp ')'\r
        ld hl,0\r
        jr z,l189ah\r
        cp '-'\r
-       jp nz,ERROR\r
+       jr nz,error9\r
 l1882h:\r
        push af\r
        inc de\r
@@ -4398,9 +4574,9 @@ l1882h:
        and a\r
        sbc hl,bc\r
 l1894h:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp ')'\r
-       jp nz,ERROR\r
+       jr nz,error9\r
 l189ah:\r
        inc de\r
        pop bc\r
@@ -4440,16 +4616,20 @@ l18b1h:
 assert_comma:\r
        call next_arg\r
        ret z\r
-l18c2h:\r
+error9:\r
        jp ERROR\r
 \r
 test_paren_close:\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp ')'\r
-       jr nz,l18c2h\r
+       jr nz,error9\r
        inc de\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+; >>L [startaddr] [endaddr]\r
+;      List disassembled code\r
+\r
 cmd_L:\r
        ld hl,cmd_L\r
        ld (cmd_rpt),hl\r
@@ -4457,8 +4637,6 @@ cmd_L:
        jr nc,l18dbh\r
        ld hl,(last_L)\r
 l18dbh:\r
-       push hl\r
-       pop iy\r
        call next_arg\r
        call get_range\r
        jr nc,l1905h\r
@@ -4466,45 +4644,37 @@ l18dbh:
        ld b,16\r
 l18ebh:\r
        push bc\r
-       push iy\r
-       pop hl\r
-       push hl\r
-       call p_disas_line\r
-       call crlf\r
-       pop iy\r
-       ld c,b\r
-       ld b,0\r
-       add iy,bc\r
-       ld (last_L),iy\r
+       call    cmdl_p_line\r
        pop bc\r
        djnz l18ebh\r
        ret\r
+\r
 l1905h:\r
        call assert_eol\r
-       ld h,b\r
-       ld l,c\r
-       ld a,b\r
-       or c\r
-       jr nz,l190fh\r
-       dec hl\r
+       ld      d,h\r
+       ld      e,l\r
+       add     hl,bc\r
+       ex      de,hl\r
 l190fh:\r
-       push hl\r
-       push iy\r
-       pop hl\r
-       push hl\r
-       call p_disas_line\r
-       call crlf\r
-       pop iy\r
-       ld e,b\r
-       ld d,000h\r
-       add iy,de\r
-       ld (last_L),iy\r
-       pop hl\r
-       and a\r
-       sbc hl,de\r
-       ret z\r
-       ret c\r
-       jr l190fh\r
+       push    de\r
+       call    cmdl_p_line\r
+       pop     de\r
+       call    cp_hl_de\r
+       jr      c,l190fh\r
+       ret\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
+cmdl_p_line:\r
+       push    hl\r
+       call    p_disas_line\r
+       call    crlf\r
+       pop     hl\r
+       ld      c,b\r
+       ld      b,0\r
+       add     hl,bc\r
+       ld      (last_L),hl\r
+       ret\r
 \r
 p_disas_line:\r
        call p_label\r
@@ -4514,12 +4684,18 @@ p_disas_line:
        call outbl\r
        sub a\r
        ld (con_col),a\r
+       push    hl\r
+       pop     iy\r
        call p_disas_instr\r
-       and a\r
        ret z\r
 \r
-       ld c,16\r
-       call p_fill_space\r
+       ld      c,15\r
+       call    p_goto_col\r
+       call    p_offset\r
+       call    outbl\r
+       jp      p_symbol\r
+\r
+;-------------------------------------------------------------------------------\r
 \r
 p_offset:\r
        ld de,(var.@)\r
@@ -4531,27 +4707,35 @@ p_offset:
        and a\r
        sbc hl,de\r
        call out_hl\r
+       add     hl,de\r
        jp out_rparen\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 p_disas_instr:\r
        sub a\r
-       ld (l1ffdh),a\r
+       ld (disas_argtype),a\r
        call disas_get_instrlen\r
        jr nc,l197fh\r
-       push bc\r
-       call p_mnemonic\r
+       push    bc\r
+       ld      a,(con_col)\r
+       add     a,5\r
+       ld      c,a\r
+       call    pstr\r
+       call    p_goto_col\r
        ex de,hl\r
        call call_hl\r
        pop bc\r
-       ld a,(l1ffdh)\r
-       ld hl,(l1ffbh)\r
+       ld a,(disas_argtype)\r
+       ld hl,(disas_arg_16)\r
+       or a\r
        scf\r
        ret\r
 \r
 l197fh:\r
        call pstr_inl\r
        DC      '???'\r
-       ld b,001h\r
+       ld b,1\r
        sub a\r
        ret\r
 \r
@@ -4587,6 +4771,8 @@ l19b1h:
        scf\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 disas_pfx.DDFD:\r
        inc iy\r
        ld hl,b_19ef_start\r
@@ -4613,6 +4799,7 @@ l19edh:
        and a\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
 ; DD/FD 3 byte (ix+d)/(iy+d)\r
 b_19ef_start:\r
        db      034h\r
@@ -4660,6 +4847,8 @@ l1a0ah:
        db      0f9h\r
        db      0\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 disas_pfx.ED:\r
        inc iy\r
        ld hl,b_1bc9_start\r
@@ -4680,6 +4869,8 @@ disas_pfx.ED:
        ld b,4\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 disas_pfx.CB:\r
        push iy\r
        inc iy\r
@@ -4694,6 +4885,8 @@ l1a42h:
        ld b,2\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 disas_nopfx:\r
        ld hl,b_1b54_start\r
        call lookup_opc\r
@@ -4713,6 +4906,8 @@ disas_nopfx:
        ld b,3\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 sub_1a72h:\r
        ld a,(hl)\r
        cp 0ffh\r
@@ -4723,14 +4918,11 @@ sub_1a72h:
        inc hl\r
        jr sub_1a72h\r
 l1a7fh:\r
+       ld de,l1c97h\r
        inc hl\r
        ld c,(hl)\r
-       ld hl,t_MNEMONICS\r
-       ld b,0\r
-       add hl,bc\r
-       ld de,l1c97h\r
-       scf\r
-       ret\r
+       jr get_mnemonic\r
+\r
 \r
 test_DDFD:\r
        ld a,(hl)\r
@@ -4756,6 +4948,7 @@ lookup_opc:
        and a\r
        jr nz,lookup_opc\r
        ret\r
+\r
 l1aa8h:\r
        inc hl\r
        ld c,(hl)\r
@@ -4763,12 +4956,14 @@ l1aa8h:
        ld e,(hl)\r
        inc hl\r
        ld d,(hl)\r
+get_mnemonic:\r
        ld hl,t_MNEMONICS\r
-       ld b,000h\r
+       ld b,0\r
        add hl,bc\r
        scf\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
 ; 1 byte opcodes (no parameters)\r
 ; Format: db opcode, t_MNEMONICS-index\r
 b_1ab6_start:\r
@@ -4788,7 +4983,7 @@ b_1ab6_start:
        db 0ffh\r
 \r
 \r
-;      1 byte opcodes\r
+; 1 byte opcodes\r
 ; Format: db mask, match, t_MNEMONICS-index\r
 ;        dw argument formating fuction\r
 b_1ad1_start:\r
@@ -4846,7 +5041,7 @@ b_1ad1_start:
        dw l1ce5h\r
        db 0\r
 \r
-;      2 byte opdodes\r
+; 2 byte opdodes\r
 b_1b54_start:\r
        db 0c7h,006h,056h       ;ld r,nn\r
        dw l1cfah\r
@@ -4867,18 +5062,18 @@ b_1b54_start:
        db 0ffh,0feh,013h       ;cp a,nn\r
        dw l1d09h\r
        db 0ffh,010h,02eh       ;djnz\r
-       dw l1d1ah\r
+       dw p_arg_jrel\r
        db 0ffh,018h,054h       ;jr\r
-       dw l1d1ah\r
-       db 0e7h,020h,054h       ;jr,cc\r
-       dw l1d0fh\r
+       dw p_arg_jrel\r
+       db 0e7h,020h,054h       ;jr cc,\r
+       dw p_arg_cc_jrel\r
        db 0ffh,0d3h,076h       ;out (nn),a\r
        dw l1d37h\r
        db 0ffh,0dbh,03fh       ;in a,(nn)\r
        dw l1d29h\r
        db 0\r
 \r
-;      3 byte opcodes\r
+; 3 byte opcodes\r
 b_1b9b_start:\r
        db 0c7h,0c2h,052h       ;jp cc,mn\r
        dw p_arg_cc_mn\r
@@ -5022,6 +5217,8 @@ b_1c55_start:
        dw p_arg_bitop\r
        db 0\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 p_arg_r_r:\r
        call p_arg_r\r
        call p_char_comma\r
@@ -5102,12 +5299,12 @@ l1d09h:
 l1d0ch:\r
        jp out_hex\r
 \r
-l1d0fh:\r
+p_arg_cc_jrel:\r
        ld a,(iy+000h)\r
        and 018h\r
        call p_arg_cc0\r
        call p_char_comma\r
-l1d1ah:\r
+p_arg_jrel:\r
        ld c,(iy+001h)\r
        ld a,c\r
        rla\r
@@ -5119,6 +5316,7 @@ l1d1ah:
        inc hl\r
        inc hl\r
        jr l1d4eh\r
+\r
 l1d29h:\r
        call p_A_comma\r
 sub_1d2ch:\r
@@ -5138,26 +5336,27 @@ p_arg_mn:
 l1d4eh:\r
        ld a,002h\r
 sub_1d50h:\r
-       ld (l1ffdh),a\r
-       ld (l1ffbh),hl\r
-       call out_hl\r
-       ret\r
+       ld (disas_argtype),a\r
+       ld (disas_arg_16),hl\r
+       jp out_hl\r
+\r
 p_arg_ww_mn:\r
        call p_arg_ww\r
        call p_char_comma\r
        jr p_arg_mn\r
 \r
 p_arg_addr_hl:\r
-       call sub_1e13h\r
+       call p_arg_addr\r
        call p_char_comma\r
        jp p_arg_hlixiy\r
+\r
 p_arg_hl_addr:\r
        call p_arg_hlixiy\r
        call p_char_comma\r
-       jp sub_1e13h\r
+       jp p_arg_addr\r
 \r
 p_arg_addr_a:\r
-       call sub_1e13h\r
+       call p_arg_addr\r
 p_char_comma_A:\r
        call p_char_comma\r
 p_char_A:\r
@@ -5165,7 +5364,7 @@ p_char_A:
        jr outchar1\r
 p_arg_a_addr:\r
        call p_A_comma\r
-       jp sub_1e13h\r
+       jp p_arg_addr\r
 l1d85h:\r
        ld a,'0'\r
        jr outchar1\r
@@ -5224,14 +5423,14 @@ l1dcah:
        jp p_arg_ww\r
 \r
 p_arg_addr_ww:\r
-       call sub_1e13h\r
+       call p_arg_addr\r
        call p_char_comma\r
        jp p_arg_ww\r
 \r
 p_arg_ww_addr:\r
        call p_arg_ww\r
        call p_char_comma\r
-       jr sub_1e13h\r
+       jr p_arg_addr\r
 \r
 p_arg_bitop:\r
        ld a,(isprefix_ixiy)\r
@@ -5264,7 +5463,7 @@ l1e0eh:
 l1e11h:\r
        jr p_arg_r0\r
 \r
-sub_1e13h:\r
+p_arg_addr:\r
        call p_char_lparen\r
        ld l,(iy+001h)\r
        ld h,(iy+002h)\r
@@ -5356,12 +5555,7 @@ p_arg:
        call sel_dc_string\r
        jp pstr\r
 \r
-p_mnemonic:\r
-       ld      a,(con_col)\r
-       add     a,5\r
-       ld      c,a\r
-       call    pstr\r
-       jp      p_fill_space\r
+;-------------------------------------------------------------------------------\r
 \r
 t_MNEMONICS:\r
        DC      'ADC'\r
@@ -5514,6 +5708,8 @@ t__C_:
        DC      '(C)'\r
        DB      0\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 sub_1ffeh:\r
        ld hl,(reg.pc)\r
        ld a,h\r
@@ -5528,7 +5724,7 @@ sub_1ffeh:
        call disas_get_instrlen\r
        jp nc,ERROR\r
        ld c,b\r
-       ld b,000h\r
+       ld b,0\r
        ld hl,(reg.pc)\r
        add hl,bc\r
        call sub_09cah\r
@@ -5545,6 +5741,8 @@ l2037h:
        scf\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 b_2039_start:\r
        db 0ffh,0ddh,000h       ;Prefix DD\r
        dw l20a7h\r
@@ -5578,6 +5776,8 @@ b_2048_start:
        dw l20c5h\r
        db 0\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 l2080h:\r
        ld a,(b_21e2_start)\r
        and a\r
@@ -5683,23 +5883,37 @@ l2113h:
 l2115h:\r
        and a\r
        ret\r
+\r
+;-------------------------------------------------------------------------------\r
+; >>C[N][J] [steps]\r
+; >>C[N][J] W expression\r
+; >>C[N][J] U expression\r
+;     trace over Calls [No list] [Jumps only] /.While./.Until.\r
+\r
 cmd_C:\r
        ld hl,cmd_C\r
-       ld a,001h\r
+       ld a,1\r
        jr l2122h\r
+\r
+;-------------------------------------------------------------------------------\r
+; >>T[N][J] [steps]\r
+; >>T[N][J] W expression\r
+; >>T[N][J] U expression\r
+;      Trace [no List] [Jumps only] / .While. / .Until.\r
+\r
 cmd_T:\r
        xor a\r
        ld hl,cmd_T\r
 l2122h:\r
        ld (cmd_rpt),hl\r
        ld (trace_call_flag),a\r
-       ld a,(de)\r
+       call get_char_upper\r
        sub 'N'\r
        jr nz,l212eh\r
        inc de\r
 l212eh:\r
        ld (trace_N_flag),a\r
-       ld a,(de)\r
+       call get_char_upper\r
        sub 'J'\r
        jr nz,l2137h\r
        inc de\r
@@ -5766,7 +5980,7 @@ sub_21a6h:
        call skipbl\r
        xor a\r
        ld (trace_UW_flag),a\r
-       ld a,(de)\r
+       call get_char_upper\r
        cp 'U'\r
        jr z,l21b5h\r
        cp 'W'\r
@@ -5800,6 +6014,8 @@ l21dah:
        cp 045h\r
        ret\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 b_21e2_start:\r
        db      0\r
 trace_call_flag:\r
@@ -5918,6 +6134,8 @@ current_cseg      defl    $
        ds      EXPR_BUF_SIZE - ($ - expr_buf)\r
 expr_bufe:\r
 \r
+;-------------------------------------------------------------------------------\r
+\r
 msg_Y:\r
        dc      'Yn'\r
 reg_Y:\r
@@ -5964,12 +6182,15 @@ isprefix_ixiy:
        db      0\r
 last_L:\r
        dw      TPA\r
-l1ffbh:\r
+disas_arg_16:\r
        dw      0\r
-l1ffdh:\r
+disas_argtype:\r
        db      0\r
 \r
-symlen_max:            ;max length of symbols read so far\r
+pbl_loop_adr:\r
+       dw      0\r
+\r
+symlen_cur:            ;max length of symbols read so far\r
        db      0\r
 cur_fcb:\r
        dw      0\r