1 ; Disassembled ddtz.com, version "DDT/Z [8101]"
2 ; with modified relocater.
5 ; - Assemble to a .REL file with M80 or a compatible assembler.
6 ; - Use Digital Research Link-80 to generate a .PRL file (op switch).
7 ; - Cut the .PRL header (first 256 byte) end rename the result to DDTZ.COM.
9 ;-------------------------------------------------------------------------------
26 ;-------------------------------------------------------------------------------
30 ; Some greneral definitions
46 BDOS_PSTR equ 9 ;Print String
48 ; ddtz specific definitions
50 STACK_SIZE equ 80 ;ddtz internal stack
51 CONBUF_SIZE equ 80 ;Size of console input buffer
52 EXPR_BUF_SIZE equ 128 ;expressen buffer for conditional breakpoints
53 BP_CNT equ 12 ;Number of breakpoints
54 BP_SIZE equ 4 ;Size of a breakpoint record
56 ;-------------------------------------------------------------------------------
68 current_cseg defl $ - current_cseg
69 .phase current_phase + current_cseg
77 db 'Z80 or better required!',cr,lf,'$'
82 ds STACK_SIZE - (current_phase - signon)
115 ;-------------------------------------------------------------------------------
150 ld hl,(1) ;wboot addr
168 ds CONBUF_SIZE + 3 - ($ - conbuf)
170 ;-------------------------------------------------------------------------------
172 ?const: jp 0 ; return console input status
173 ?conin: jp 0 ; return console input character
174 ?cono: jp 0 ; send console output character
175 ?list: jp 0 ; send list output character
176 ?auxo: jp 0 ; send auxiliary output character
177 ?auxi: jp 0 ; return auxiliary input character
180 dw ERROR ;cmd_@ ;examine/substitute the displacement register @
181 dw ERROR ;cmd_A ;Assemble
182 dw cmd_B ;Breakpoints display/set/clear
183 dw ERROR ;cmd_C ;trace over Calls
184 dw cmd_D ;Display memory in hex and ascii
186 dw ERROR ;cmd_F ;specify Filename and command line
188 dw cmd_H ;compute Hex and other expressions
189 dw cmd_I ;Input a byte from port
192 dw cmd_L ;List disassembled code
193 dw cmd_M ;Move memory [and verify]
195 dw cmd_O ;Output a byte to port
197 dw cmd_Q ;Qery memory for byte string
198 dw cmd_R ;Read binary or hex file
199 dw cmd_S ;Substitute memory
202 dw cmd_V ;Verify (compare) two memory areas
203 dw ERROR ;cmd_W ;Write a file to disk
204 dw cmd_X ;eXamine [and substitute] registers
205 dw ERROR ;cmd_Y ;examine [and substitute] Y variables
206 dw cmd_Z ;Zap (fill) memory with a byte string
217 call bp_clr_temporary
247 ;-------------------------------------------------------------------------------
267 defb 03eh ;ld a,.. swallow push hl
418 ;-------------------------------------------------------------------------------
425 ;-------------------------------------------------------------------------------
444 ;-------------------------------------------------------------------------------
469 ;-------------------------------------------------------------------------------
484 jr z,inl_e ;Accept line
486 jr z,inl_e ;Accept line
493 call DELC ;Delete Char
498 call DELL ;Delete Line
508 ld a,'^' ;Controll characters
529 ;-------------------------------------------------------------------------------
542 ;-------------------------------------------------------------------------------
555 ;-------------------------------------------------------------------------------
571 ;-------------------------------------------------------------------------------
578 ld de,stack-(STACK_SIZE-28)
585 ;-------------------------------------------------------------------------------
599 ;-------------------------------------------------------------------------------
717 defb 0e6h ;and a,.. clear carry
729 defb 03eh ;ld a,.. swallow pop af
771 jr z,error0 ;'S', but no expression following
775 ;-------------------------------------------------------------------------------
796 ;-------------------------------------------------------------------------------
841 ld hl,tab_func_eqlege
943 ; de: x (x shifted out, q shifted in)
945 ; hl: r (initially 0)
1020 ;-------------------------------------------------------------------------------
1063 jr z,fact_factstring
1068 ;-------------------------------------------------------------------------------
1154 ;-------------------------------------------------------------------------------
1262 ;-------------------------------------------------------------------------------
1309 ld hl,t_flag_names+7
1404 ;-------------------------------------------------------------------------------
1405 ; > G [startaddr] [;breakp..]
1406 ; Go [to start] [with temporary breakpoints]
1410 ld (bp_p_cpu_flag),a
1425 ;-------------------------------------------------------------------------------
1431 ld (pbl_loop_adr),hl
1444 ld hl,(pbl_loop_adr)
1458 ;-------------------------------------------------------------------------------
1460 ; display all breakpoints
1461 ; > B breakp [breakp..]
1464 ; clear all breakpoints
1465 ; > BX breakp [breakp..]
1468 ; breakp can be any valid expression
1528 ;-------------------------------------------------------------------------------
1529 ; Add break points to list
1530 ; A = 1 Permanent (B command)
1531 ; A = 2 Temporary (G command)
1548 call bp_get_freeslot
1570 ;-------------------------------------------------------------------------------
1571 ; Breakpoint handling routine.
1605 call inchar ;Keyboard hit?
1613 call bp_clr_temporary
1626 ld (bp_p_cpu_flag),a
1683 call bp_get_freeslot
1722 ;-------------------------------------------------------------------------------
1727 ld a,(bp_p_cpu_flag)
1757 ;-------------------------------------------------------------------------------
1759 ; examine all Y variables
1761 ; examine (and substitute) an Y variable
1764 ;-------------------------------------------------------------------------------
1766 ; eXamine (display) all cpu registers and
1767 ; the instruction at the current program counter
1769 ; eXamine (and substitute) a register
1996 ;-------------------------------------------------------------------------------
2002 call get_lastarg_def
2036 ;-------------------------------------------------------------------------------
2038 ; examine (substitute) displacement register @
2042 ;-------------------------------------------------------------------------------
2044 ; Input a byte from port
2049 call get_lastarg_def
2061 ;-------------------------------------------------------------------------------
2063 ; Output a byte to a port
2074 call get_lastarg_def
2082 ;-------------------------------------------------------------------------------
2083 ; > Vstartaddr endaddr targetaddr
2084 ; Verify (compare) two memory areas
2114 ;-------------------------------------------------------------------------------
2115 ; > M startaddr endaddr destaddr
2129 db 01h ;swallow ldir instruction (ld bc,...)
2134 ;-------------------------------------------------------------------------------
2136 ; display Highest load address of last filed loaded, Maximum "High"
2137 ; off all loaded files, and Top address of available memory
2139 ; evaluate expression and display result in hex, decimal and other formats
2159 ;-------------------------------------------------------------------------------
2160 ; > Q[J] startaddr endaddr bytes
2161 ; Query memory for a byte string [Justified]
2201 ;-------------------------------------------------------------------------------
2202 ; > Z startaddr endaddr bytes
2203 ; Zap (fill) memory with a byte string
2237 sub_0ef7h: ;from cmd_Q, cmd_Z
2238 db 0e6h ;and 037h (clear carry)
2239 sub_0ef8h: ;from cmd_S
2288 ;-------------------------------------------------------------------------------
2289 ; >>D [startaddr] [endaddr]
2290 ; Display memory in hex and ASCII
2358 ;-------------------------------------------------------------------------------
2360 ; specifiy filenames and command line
2364 ;-------------------------------------------------------------------------------
2365 ; > R [displacement]
2366 ; Read Intel Hex File from console [add displacement]
2370 call get_lastarg_def ;get offset from command line
2379 ld c,0 ;init checksum
2380 call i.gethexbyte ;record len
2382 call i.gethexbyte ;address high
2384 call i.gethexbyte ;address low
2386 call i.gethexbyte ;record type (ignored)
2388 and a ;record len == 0?
2399 djnz l16c6h ;repeat for record len
2400 call i.gethexbyte ;checksum
2403 jp nz,ERROR ;exit if checksum error
2404 jr w_recstart ;next record
2441 ld de,TPA ;lowest allowed load address
2444 ld de,(BDOS+1) ;highest allowed load address
2459 ld (hl),a ;store byte
2462 ;-------------------------------------------------------------------------------
2481 ;-------------------------------------------------------------------------------
2482 ; > Wstartaddr endaddr
2483 ; Write a file to disk
2487 ;-------------------------------------------------------------------------------
2489 ; Assemble Zilog Z180 mnemonics
2497 ;-------------------------------------------------------------------------------
2511 ;-------------------------------------------------------------------------------
2512 ; >>L [startaddr] [endaddr]
2513 ; List disassembled code
2547 ;-------------------------------------------------------------------------------
2575 ;-------------------------------------------------------------------------------
2578 ;-------------------------------------------------------------------------------
2582 ld (disas_argtype),a
2583 call disas_get_instrlen
2594 ld a,(disas_argtype)
2595 ld hl,(disas_arg_16)
2609 ld (isprefix_ixiy),a
2628 ld (isprefix_ixiy),a
2639 ;-------------------------------------------------------------------------------
2667 ;-------------------------------------------------------------------------------
2668 ; DD/FD 3 byte (ix+d)/(iy+d)
2715 ;-------------------------------------------------------------------------------
2737 ;-------------------------------------------------------------------------------
2742 ld a,(isprefix_ixiy)
2753 ;-------------------------------------------------------------------------------
2774 ;-------------------------------------------------------------------------------
2831 ;-------------------------------------------------------------------------------
2832 ; 1 byte opcodes (no parameters)
2833 ; Format: db opcode, t_MNEMONICS-index
2852 ; Format: db mask, match, t_MNEMONICS-index
2853 ; dw argument formating fuction
2855 db 0c0h,040h,056h ;ld r,r
2857 db 0f8h,080h,003h ;add a,r
2859 db 0f8h,088h,000h ;adc a,r
2861 db 0f8h,090h,0c9h ;sub r
2863 db 0f8h,098h,0b7h ;sbc a,r
2865 db 0f8h,0a0h,006h ;and r
2867 db 0f8h,0a8h,0cch ;xor r
2869 db 0f8h,0b0h,06ch ;or r
2871 db 0f8h,0b8h,013h ;cp r
2873 db 0c7h,0c0h,08bh ;ret cc
2875 db 0c7h,0c7h,0b4h ;rst
2877 db 0ffh,0c9h,08bh ;ret
2879 db 0cfh,0c1h,081h ;pop rr
2881 db 0cfh,0c5h,084h ;push rr
2883 db 0ffh,0e3h,034h ;ex (sp),hl
2885 db 0ffh,0e9h,052h ;jp (hl)
2887 db 0ffh,0ebh,034h ;ex de,hl
2889 db 0ffh,0f9h,056h ;ld sp,hl
2891 db 0cfh,003h,041h ;inc rr
2893 db 0cfh,00bh,029h ;dec rr
2895 db 0c7h,004h,041h ;inc r
2897 db 0c7h,005h,029h ;dec r
2899 db 0ffh,008h,034h ;ex af,af'
2901 db 0cfh,009h,003h ;add hl,rr
2903 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
2905 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
2911 db 0c7h,006h,056h ;ld r,nn
2913 db 0ffh,0c6h,003h ;add a,nn
2915 db 0ffh,0ceh,000h ;adc a,nn
2917 db 0ffh,0d6h,0c9h ;sub a,nn
2919 db 0ffh,0deh,0b7h ;sbc a,nn
2921 db 0ffh,0e6h,006h ;and a,nn
2923 db 0ffh,0eeh,0cch ;xor nn
2925 db 0ffh,0f6h,06ch ;or nn
2927 db 0ffh,0feh,013h ;cp a,nn
2929 db 0ffh,010h,02eh ;djnz
2931 db 0ffh,018h,054h ;jr
2933 db 0e7h,020h,054h ;jr cc,
2935 db 0ffh,0d3h,076h ;out (nn),a
2937 db 0ffh,0dbh,03fh ;in a,(nn)
2943 db 0c7h,0c2h,052h ;jp cc,mn
2945 db 0c7h,0c4h,00ch ;call cc,mn
2947 db 0cfh,001h,056h ;ld ww,mn
2949 db 0ffh,0c3h,052h ;jp mn
2951 db 0ffh,0cdh,00ch ;call mn
2953 db 0ffh,022h,056h ;ld (mn),hl
2955 db 0ffh,02ah,056h ;ld hl,(mn)
2957 db 0ffh,032h,056h ;ld (mn),a
2959 db 0ffh,03ah,056h ;ld a,(mn)
2963 ; Prefix ED + 1 byte opcode, no arguments
2964 ; Format: opcode, t_MNEMONICS index
2995 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
2997 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
2999 db 0ffh,078h,03fh ;in r,(c) ;r=a
3001 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
3003 db 0f7h,061h,076h ;out (c),r ;r=h,l
3005 db 0ffh,079h,076h ;out (c),r ;r=a
3007 db 0cfh,042h,0b7h ;sbc hl,rr
3009 db 0cfh,04ah,000h ;adc hl,rr
3011 db 0ffh,046h,03dh ;im 0
3013 db 0ffh,056h,03dh ;im 1
3015 db 0ffh,05eh,03dh ;im 2
3017 db 0ffh,047h,056h ;ld i,a
3019 db 0ffh,057h,056h ;ld a,i
3021 db 0ffh,04fh,056h ;ld r,a
3023 db 0ffh,05fh,056h ;ld a,r
3025 db 0cfh,04ch,0d2h ;mlt rr
3027 db 0c7h,004h,0eeh ;tst r
3032 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
3034 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
3036 db 0ffh,038h,0cfh ;in0 a,(m)
3038 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
3040 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
3042 db 0ffh,039h,0e7h ;out0 (m),a
3044 db 0ffh,064h,0eeh ;tst m
3046 db 0ffh,074h,0f1h ;tstio m
3051 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
3053 db 0ffh,073h,056h ;ld (mn),sp
3055 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
3057 db 0ffh,07bh,056h ;ld sp,(mn)
3063 db 0f8h,000h,09bh ;rlc g
3065 db 0f8h,008h,0aah ;rrc g
3067 db 0f8h,010h,096h ;rl g
3069 db 0f8h,018h,0a5h ;rr g
3071 db 0f8h,020h,0c0h ;sla g
3073 db 0f8h,028h,0c3h ;sra g
3075 db 0f8h,038h,0c6h ;srl g
3077 db 0c0h,040h,009h ;bit b,g
3079 db 0c0h,080h,088h ;res b,g
3081 db 0c0h,0c0h,0bdh ;set b,g
3085 ;-------------------------------------------------------------------------------
3157 ld a,(isprefix_ixiy)
3207 ld (disas_argtype),a
3208 ld (disas_arg_16),hl
3317 ld a,(isprefix_ixiy)
3337 ld a,(isprefix_ixiy)
3359 ld a,(isprefix_ixiy)
3364 ld a,(isprefix_ixiy)
3394 ld a,(isprefix_ixiy)
3426 ;-------------------------------------------------------------------------------
3557 ;-------------------------------------------------------------------------------
3567 ld hl,l20edh ;set break after BDOS call
3570 call disas_get_instrlen
3585 call c,bp_trace_enter
3590 ;-------------------------------------------------------------------------------
3593 db 0ffh,0ddh,000h ;Prefix DD
3595 db 0ffh,0fdh,000h ;Prefix FD
3597 db 0ffh,0edh,000h ;Prefix ED
3601 db 0ffh,0cdh,000h ;call mn
3603 db 0ffh,0c3h,000h ;jp mn
3605 db 0ffh,0e9h,000h ;jp ()
3607 db 0ffh,0c9h,000h ;ret
3609 db 0ffh,0cfh,000h ;rst 8
3611 db 0c7h,0c7h,000h ;rst n
3613 db 0c7h,0c4h,000h ;call cc,mn
3615 db 0f7h,010h,000h ;djnz d; jr d
3617 db 0e7h,020h,000h ;jr cc,d
3619 db 0c7h,0c2h,000h ;jp cc,mn
3621 db 0c7h,0c0h,000h ;ret cc
3625 ;-------------------------------------------------------------------------------
3626 ; call mn call cc,mn
3664 cp 0e9h ; jp (ix); jp (iy)
3698 ld hl,(reg_sp) ;break on return address
3723 ;-------------------------------------------------------------------------------
3725 ; >>C[N][J] W expression
3726 ; >>C[N][J] U expression
3727 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3730 ;-------------------------------------------------------------------------------
3732 ; >>T[N][J] W expression
3733 ; >>T[N][J] U expression
3734 ; Trace [no List] [Jumps only] / .While. / .Until.
3738 ld hl,1 ;default: 1 step
3739 call get_lastarg_def
3740 ld (trace_cnt_or_ptr),hl
3742 ld (bp_p_cpu_flag),a
3747 call bp_clr_temporary
3748 ld hl,(trace_cnt_or_ptr)
3750 ld (trace_cnt_or_ptr),hl
3758 ld (bp_p_cpu_flag),a
3762 ;-------------------------------------------------------------------------------
3767 ;-------------------------------------------------------------------------------
3785 current_cseg defl $ - current_cseg
3786 .phase current_phase + current_cseg
3789 LD SP,ldr_end+(stack-ddtz_base)
3790 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
3803 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
3804 ld bc,0108h ;init bit counter
3808 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
3812 INC DE ;size rounded up to next page boundary
3815 SBC HL,DE ;BDOS - size
3816 LD (BDOS+1),HL ;-> new BDOS entry
3831 ld b,c ;reload bit counter
3832 LD e,(HL) ;get next 8 relocation bits
3858 LD HL,conbuf+2-ddtz_base
3862 current_phase defl $
3866 ds EXPR_BUF_SIZE - ($ - expr_buf)
3869 ;-------------------------------------------------------------------------------
3902 ddtz_size equ $-ddtz_base
3905 ;-------------------------------------------------------------------------------