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_CIN equ 1 ;Console Input
47 BDOS_COUT equ 2 ;Console Output
48 BDOS_PSTR equ 9 ;Print String
49 BDOS_CBUF equ 10 ;Read Console Buffer
50 BDOS_CSTAT equ 11 ;Get Console Status
51 BDOS_OPEN equ 15 ;Open File
52 BDOS_CLOSE equ 16 ;Close File
53 BDOS_DELETE equ 19 ;Delete File
54 BDOS_READ equ 20 ;Read Sequential
55 BDOS_WRITE equ 21 ;Write Sequential
56 BDOS_CREATE equ 22 ;Make File
57 BDOS_SETDMA equ 26 ;Set DMA Address
59 ; ddtz specific definitions
61 STACK_SIZE equ 80 ;ddtz internal stack
62 CONBUF_SIZE equ 80 ;Size of console input buffer
63 EXPR_BUF_SIZE equ 128 ;expressen buffer for conditional breakpoints
64 BP_CNT equ 12 ;Number of breakpoints
65 BP_SIZE equ 6 ;Size of a breakpoint record
67 ;-------------------------------------------------------------------------------
79 current_cseg defl $ - current_cseg
80 .phase current_phase + current_cseg
88 db 'Z80 or better required!',cr,lf,'$'
93 ds STACK_SIZE - (current_phase - signon)
126 ;-------------------------------------------------------------------------------
166 ds CONBUF_SIZE + 3 - ($ - conbuf)
168 ;-------------------------------------------------------------------------------
171 dw ERROR ;cmd_@ ;examine/substitute the displacement register @
172 dw ERROR ;cmd_A ;Assemble
173 dw cmd_B ;Breakpoints display/set/clear
174 dw ERROR ;cmd_C ;trace over Calls
175 dw cmd_D ;Display memory in hex and ascii
177 dw cmd_F ;specify Filename and command line
179 dw cmd_H ;compute Hex and other expressions
180 dw cmd_I ;Input a byte from port
183 dw cmd_L ;List disassembled code
184 dw cmd_M ;Move memory [and verify]
186 dw cmd_O ;Output a byte to port
188 dw cmd_Q ;Qery memory for byte string
189 dw cmd_R ;Read binary or hex file
190 dw cmd_S ;Substitute memory
193 dw cmd_V ;Verify (compare) two memory areas
194 dw cmd_W ;Write a file to disk
195 dw cmd_X ;eXamine [and substitute] registers
196 dw ERROR ;cmd_Y ;examine [and substitute] Y variables
197 dw cmd_Z ;Zap (fill) memory with a byte string
208 call bp_clr_temporary
238 ;-------------------------------------------------------------------------------
258 defb 03eh ;ld a,.. swallow push hl
411 ;-------------------------------------------------------------------------------
449 ;-------------------------------------------------------------------------------
462 ;-------------------------------------------------------------------------------
488 ;-------------------------------------------------------------------------------
495 ld de,stack-(STACK_SIZE-28)
502 ;-------------------------------------------------------------------------------
516 ;-------------------------------------------------------------------------------
634 defb 0e6h ;and a,.. clear carry
646 defb 03eh ;ld a,.. swallow pop af
688 jr z,error0 ;'S', but no expression following
692 ;-------------------------------------------------------------------------------
713 ;-------------------------------------------------------------------------------
758 ld hl,tab_func_eqlege
860 ; de: x (x shifted out, q shifted in)
862 ; hl: r (initially 0)
937 ;-------------------------------------------------------------------------------
985 ;-------------------------------------------------------------------------------
1071 ;-------------------------------------------------------------------------------
1179 ;-------------------------------------------------------------------------------
1226 ld hl,t_flag_names+7
1321 ;-------------------------------------------------------------------------------
1322 ; > G [startaddr] [;breakp..]
1323 ; Go [to start] [with temporary breakpoints]
1327 ld (bp_p_cpu_flag),a
1342 ;-------------------------------------------------------------------------------
1348 ld (pbl_loop_adr),hl
1361 ld hl,(pbl_loop_adr)
1375 ;-------------------------------------------------------------------------------
1377 ; display all breakpoints
1378 ; > B breakp [breakp..]
1381 ; clear all breakpoints
1382 ; > BX address [address..]
1446 ;-------------------------------------------------------------------------------
1447 ; Add break points to list
1448 ; A = 1 Permanent (B command)
1449 ; A = 2 Temporary (G command)
1466 call bp_get_freeslot
1500 ;-------------------------------------------------------------------------------
1501 ; Breakpoint handling routine.
1535 call inchar ;Keyboard hit?
1543 call bp_clr_temporary
1556 ld (bp_p_cpu_flag),a
1631 call bp_get_freeslot
1672 ;-------------------------------------------------------------------------------
1677 ld a,(bp_p_cpu_flag)
1707 ;-------------------------------------------------------------------------------
1709 ; examine all Y variables
1711 ; examine (and substitute) an Y variable
1714 ;-------------------------------------------------------------------------------
1716 ; eXamine (display) all cpu registers and
1717 ; the instruction at the current program counter
1719 ; eXamine (and substitute) a register
1946 ;-------------------------------------------------------------------------------
1952 call get_lastarg_def
1986 ;-------------------------------------------------------------------------------
1988 ; examine (substitute) displacement register @
1992 ;-------------------------------------------------------------------------------
1994 ; Input a byte from port
1999 call get_lastarg_def
2011 ;-------------------------------------------------------------------------------
2013 ; Output a byte to a port
2024 call get_lastarg_def
2032 ;-------------------------------------------------------------------------------
2033 ; > Vstartaddr endaddr targetaddr
2034 ; Verify (compare) two memory areas
2067 ;-------------------------------------------------------------------------------
2068 ; > M[V] startaddr endaddr destaddr
2069 ; Move memory [and verify]
2091 db 01h ;swallow ldir instruction (ld bc,...)
2101 ;-------------------------------------------------------------------------------
2103 ; display Highest load address of last filed loaded, Maximum "High"
2104 ; off all loaded files, and Top address of available memory
2106 ; evaluate expression and display result in hex, decimal and other formats
2126 ;-------------------------------------------------------------------------------
2127 ; > Q[J] startaddr endaddr bytes
2128 ; Query memory for a byte string [Justified]
2169 ;-------------------------------------------------------------------------------
2170 ; > Z startaddr endaddr bytes
2171 ; Zap (fill) memory with a byte string
2223 db 0e6h ; and 037h (clear carry)
2286 ;-------------------------------------------------------------------------------
2287 ; >>D [startaddr] [endaddr]
2288 ; Display memory in hex and ASCII
2357 ;-------------------------------------------------------------------------------
2359 ; specifiy filenames and command line
2482 ;-------------------------------------------------------------------------------
2500 ;-------------------------------------------------------------------------------
2609 ;-------------------------------------------------------------------------------
2610 ; > R [displacement]
2611 ; Read a binary or hex file [add displacement]
2615 call get_lastarg_def
2651 call read_byte ; RECORD MARK
2656 call read_hexchar ; RECLEN
2658 call read_hexchar ; LOAD ADDR H
2660 call read_hexchar ; LOAD ADDR L
2665 call read_hexchar ; RECTYP
2667 call read_hexchar ; DATA
2676 call read_hexchar ; CHKSUM
2691 ;-------------------------------------------------------------------------------
2710 ;-------------------------------------------------------------------------------
2711 ; > Wstartaddr endaddr
2712 ; Write a file to disk
2746 ld de,080h ; DMA_BUF
2775 ;-------------------------------------------------------------------------------
2777 ; Assemble Zilog Z180 mnemonics
2785 ;-------------------------------------------------------------------------------
2799 ;-------------------------------------------------------------------------------
2800 ; >>L [startaddr] [endaddr]
2801 ; List disassembled code
2835 ;-------------------------------------------------------------------------------
2863 ;-------------------------------------------------------------------------------
2866 ;-------------------------------------------------------------------------------
2870 ld (disas_argtype),a
2871 call disas_get_instrlen
2882 ld a,(disas_argtype)
2883 ld hl,(disas_arg_16)
2897 ld (isprefix_ixiy),a
2916 ld (isprefix_ixiy),a
2927 ;-------------------------------------------------------------------------------
2955 ;-------------------------------------------------------------------------------
2956 ; DD/FD 3 byte (ix+d)/(iy+d)
3003 ;-------------------------------------------------------------------------------
3025 ;-------------------------------------------------------------------------------
3030 ld a,(isprefix_ixiy)
3041 ;-------------------------------------------------------------------------------
3062 ;-------------------------------------------------------------------------------
3119 ;-------------------------------------------------------------------------------
3120 ; 1 byte opcodes (no parameters)
3121 ; Format: db opcode, t_MNEMONICS-index
3140 ; Format: db mask, match, t_MNEMONICS-index
3141 ; dw argument formating fuction
3143 db 0c0h,040h,056h ;ld r,r
3145 db 0f8h,080h,003h ;add a,r
3147 db 0f8h,088h,000h ;adc a,r
3149 db 0f8h,090h,0c9h ;sub r
3151 db 0f8h,098h,0b7h ;sbc a,r
3153 db 0f8h,0a0h,006h ;and r
3155 db 0f8h,0a8h,0cch ;xor r
3157 db 0f8h,0b0h,06ch ;or r
3159 db 0f8h,0b8h,013h ;cp r
3161 db 0c7h,0c0h,08bh ;ret cc
3163 db 0c7h,0c7h,0b4h ;rst
3165 db 0ffh,0c9h,08bh ;ret
3167 db 0cfh,0c1h,081h ;pop rr
3169 db 0cfh,0c5h,084h ;push rr
3171 db 0ffh,0e3h,034h ;ex (sp),hl
3173 db 0ffh,0e9h,052h ;jp (hl)
3175 db 0ffh,0ebh,034h ;ex de,hl
3177 db 0ffh,0f9h,056h ;ld sp,hl
3179 db 0cfh,003h,041h ;inc rr
3181 db 0cfh,00bh,029h ;dec rr
3183 db 0c7h,004h,041h ;inc r
3185 db 0c7h,005h,029h ;dec r
3187 db 0ffh,008h,034h ;ex af,af'
3189 db 0cfh,009h,003h ;add hl,rr
3191 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
3193 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
3199 db 0c7h,006h,056h ;ld r,nn
3201 db 0ffh,0c6h,003h ;add a,nn
3203 db 0ffh,0ceh,000h ;adc a,nn
3205 db 0ffh,0d6h,0c9h ;sub a,nn
3207 db 0ffh,0deh,0b7h ;sbc a,nn
3209 db 0ffh,0e6h,006h ;and a,nn
3211 db 0ffh,0eeh,0cch ;xor nn
3213 db 0ffh,0f6h,06ch ;or nn
3215 db 0ffh,0feh,013h ;cp a,nn
3217 db 0ffh,010h,02eh ;djnz
3219 db 0ffh,018h,054h ;jr
3221 db 0e7h,020h,054h ;jr cc,
3223 db 0ffh,0d3h,076h ;out (nn),a
3225 db 0ffh,0dbh,03fh ;in a,(nn)
3231 db 0c7h,0c2h,052h ;jp cc,mn
3233 db 0c7h,0c4h,00ch ;call cc,mn
3235 db 0cfh,001h,056h ;ld ww,mn
3237 db 0ffh,0c3h,052h ;jp mn
3239 db 0ffh,0cdh,00ch ;call mn
3241 db 0ffh,022h,056h ;ld (mn),hl
3243 db 0ffh,02ah,056h ;ld hl,(mn)
3245 db 0ffh,032h,056h ;ld (mn),a
3247 db 0ffh,03ah,056h ;ld a,(mn)
3251 ; Prefix ED + 1 byte opcode, no arguments
3252 ; Format: opcode, t_MNEMONICS index
3283 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
3285 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
3287 db 0ffh,078h,03fh ;in r,(c) ;r=a
3289 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
3291 db 0f7h,061h,076h ;out (c),r ;r=h,l
3293 db 0ffh,079h,076h ;out (c),r ;r=a
3295 db 0cfh,042h,0b7h ;sbc hl,rr
3297 db 0cfh,04ah,000h ;adc hl,rr
3299 db 0ffh,046h,03dh ;im 0
3301 db 0ffh,056h,03dh ;im 1
3303 db 0ffh,05eh,03dh ;im 2
3305 db 0ffh,047h,056h ;ld i,a
3307 db 0ffh,057h,056h ;ld a,i
3309 db 0ffh,04fh,056h ;ld r,a
3311 db 0ffh,05fh,056h ;ld a,r
3313 db 0cfh,04ch,0d2h ;mlt rr
3315 db 0c7h,004h,0eeh ;tst r
3320 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
3322 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
3324 db 0ffh,038h,0cfh ;in0 a,(m)
3326 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
3328 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
3330 db 0ffh,039h,0e7h ;out0 (m),a
3332 db 0ffh,064h,0eeh ;tst m
3334 db 0ffh,074h,0f1h ;tstio m
3339 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
3341 db 0ffh,073h,056h ;ld (mn),sp
3343 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
3345 db 0ffh,07bh,056h ;ld sp,(mn)
3351 db 0f8h,000h,09bh ;rlc g
3353 db 0f8h,008h,0aah ;rrc g
3355 db 0f8h,010h,096h ;rl g
3357 db 0f8h,018h,0a5h ;rr g
3359 db 0f8h,020h,0c0h ;sla g
3361 db 0f8h,028h,0c3h ;sra g
3363 db 0f8h,038h,0c6h ;srl g
3365 db 0c0h,040h,009h ;bit b,g
3367 db 0c0h,080h,088h ;res b,g
3369 db 0c0h,0c0h,0bdh ;set b,g
3373 ;-------------------------------------------------------------------------------
3445 ld a,(isprefix_ixiy)
3495 ld (disas_argtype),a
3496 ld (disas_arg_16),hl
3605 ld a,(isprefix_ixiy)
3625 ld a,(isprefix_ixiy)
3647 ld a,(isprefix_ixiy)
3652 ld a,(isprefix_ixiy)
3682 ld a,(isprefix_ixiy)
3714 ;-------------------------------------------------------------------------------
3845 ;-------------------------------------------------------------------------------
3858 call disas_get_instrlen
3873 call c,bp_trace_enter
3878 ;-------------------------------------------------------------------------------
3881 db 0ffh,0ddh,000h ;Prefix DD
3883 db 0ffh,0fdh,000h ;Prefix FD
3885 db 0ffh,0edh,000h ;Prefix ED
3889 db 0ffh,0cdh,000h ;call mn
3891 db 0ffh,0c3h,000h ;jp mn
3893 db 0ffh,0e9h,000h ;jp ()
3895 db 0ffh,0c9h,000h ;ret
3897 db 0ffh,0cfh,000h ;rst 8
3899 db 0c7h,0c7h,000h ;rst n
3901 db 0c7h,0c4h,000h ;call cc,mn
3903 db 0f7h,010h,000h ;djnz d; jr d
3905 db 0e7h,020h,000h ;jr cc,d
3907 db 0c7h,0c2h,000h ;jp cc,mn
3909 db 0c7h,0c0h,000h ;ret cc
3913 ;-------------------------------------------------------------------------------
3914 ; call mn call cc,mn
3952 cp 0e9h ; jp (ix); jp (iy)
4011 ;-------------------------------------------------------------------------------
4013 ; >>C[N][J] W expression
4014 ; >>C[N][J] U expression
4015 ; trace over Calls [No list] [Jumps only] /.While./.Until.
4018 ;-------------------------------------------------------------------------------
4020 ; >>T[N][J] W expression
4021 ; >>T[N][J] U expression
4022 ; Trace [no List] [Jumps only] / .While. / .Until.
4026 ld hl,1 ;default: 1 step
4027 call get_lastarg_def
4028 ld (trace_cnt_or_ptr),hl
4030 ld (bp_p_cpu_flag),a
4035 call bp_clr_temporary
4036 ld hl,(trace_cnt_or_ptr)
4038 ld (trace_cnt_or_ptr),hl
4046 ld (bp_p_cpu_flag),a
4050 ;-------------------------------------------------------------------------------
4055 ;-------------------------------------------------------------------------------
4073 current_cseg defl $ - current_cseg
4074 .phase current_phase + current_cseg
4077 LD SP,ldr_end+(stack-ddtz_base)
4078 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
4091 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
4092 ld bc,0108h ;init bit counter
4096 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
4100 INC DE ;size rounded up to next page boundary
4103 SBC HL,DE ;BDOS - size
4104 LD (BDOS+1),HL ;-> new BDOS entry
4119 ld b,c ;reload bit counter
4120 LD e,(HL) ;get next 8 relocation bits
4146 LD HL,conbuf+2-ddtz_base
4150 current_phase defl $
4154 ds EXPR_BUF_SIZE - ($ - expr_buf)
4157 ;-------------------------------------------------------------------------------
4199 ddtz_size equ $-ddtz_base
4202 ;-------------------------------------------------------------------------------