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 8 ;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 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
239 ;-------------------------------------------------------------------------------
259 defb 03eh ;ld a,.. swallow push hl
412 ;-------------------------------------------------------------------------------
450 ;-------------------------------------------------------------------------------
463 ;-------------------------------------------------------------------------------
489 ;-------------------------------------------------------------------------------
496 ld de,stack-(STACK_SIZE-28)
503 ;-------------------------------------------------------------------------------
517 ;-------------------------------------------------------------------------------
635 defb 0e6h ;and a,.. clear carry
647 defb 03eh ;ld a,.. swallow pop af
689 jr z,error0 ;'S', but no expression following
693 ;-------------------------------------------------------------------------------
714 ;-------------------------------------------------------------------------------
759 ld hl,tab_func_eqlege
861 ; de: x (x shifted out, q shifted in)
863 ; hl: r (initially 0)
938 ;-------------------------------------------------------------------------------
986 ;-------------------------------------------------------------------------------
1072 ;-------------------------------------------------------------------------------
1180 ;-------------------------------------------------------------------------------
1227 ld hl,t_flag_names+7
1322 ;-------------------------------------------------------------------------------
1323 ; > G [startaddr] [;breakp..]
1324 ; Go [to start] [with temporary breakpoints]
1328 ld (trace_call_flag),a
1329 ld (bp_p_cpu_flag),a
1344 ;-------------------------------------------------------------------------------
1350 ld (pbl_loop_adr),hl
1363 ld hl,(pbl_loop_adr)
1373 call bp_clr_condition
1378 ;-------------------------------------------------------------------------------
1380 ; display all breakpoints
1381 ; > B breakp [breakp..]
1384 ; clear all breakpoints
1385 ; > BX address [address..]
1389 ; [R] expression [I condition]
1426 call bp_clr_condition
1467 ;-------------------------------------------------------------------------------
1468 ; Add break points to list
1469 ; A = 1 Permanent (B command)
1470 ; A = 2 Temporary (G command)
1491 call bp_get_freeslot
1498 call bp_get_condition
1555 ld (hl),c ; trailing 0
1561 ;-------------------------------------------------------------------------------
1562 ; Breakpoint handling routine.
1596 call inchar ;Keyboard hit?
1604 call bp_clr_temporary
1617 ld (bp_p_cpu_flag),a
1661 ld (bp_p_cpu_flag),a
1706 call bp_get_freeslot
1749 ;-------------------------------------------------------------------------------
1754 ld a,(bp_p_cpu_flag)
1784 ;-------------------------------------------------------------------------------
1838 ;-------------------------------------------------------------------------------
1840 ; examine all Y variables
1842 ; examine (and substitute) an Y variable
1845 ;-------------------------------------------------------------------------------
1847 ; eXamine (display) all cpu registers and
1848 ; the instruction at the current program counter
1850 ; eXamine (and substitute) a register
2078 ;-------------------------------------------------------------------------------
2084 call get_lastarg_def
2118 ;-------------------------------------------------------------------------------
2120 ; examine (substitute) displacement register @
2124 ;-------------------------------------------------------------------------------
2126 ; Input a byte from port
2131 call get_lastarg_def
2143 ;-------------------------------------------------------------------------------
2145 ; Output a byte to a port
2156 call get_lastarg_def
2164 ;-------------------------------------------------------------------------------
2165 ; > Vstartaddr endaddr targetaddr
2166 ; Verify (compare) two memory areas
2199 ;-------------------------------------------------------------------------------
2200 ; > M[V] startaddr endaddr destaddr
2201 ; Move memory [and verify]
2223 db 01h ;swallow ldir instruction (ld bc,...)
2233 ;-------------------------------------------------------------------------------
2235 ; display Highest load address of last filed loaded, Maximum "High"
2236 ; off all loaded files, and Top address of available memory
2238 ; evaluate expression and display result in hex, decimal and other formats
2258 ;-------------------------------------------------------------------------------
2259 ; > Q[J] startaddr endaddr bytes
2260 ; Query memory for a byte string [Justified]
2301 ;-------------------------------------------------------------------------------
2302 ; > Z startaddr endaddr bytes
2303 ; Zap (fill) memory with a byte string
2355 db 0e6h ; and 037h (clear carry)
2418 ;-------------------------------------------------------------------------------
2419 ; >>D [startaddr] [endaddr]
2420 ; Display memory in hex and ASCII
2489 ;-------------------------------------------------------------------------------
2491 ; specifiy filenames and command line
2614 ;-------------------------------------------------------------------------------
2632 ;-------------------------------------------------------------------------------
2741 ;-------------------------------------------------------------------------------
2742 ; > R [displacement]
2743 ; Read a binary or hex file [add displacement]
2747 call get_lastarg_def
2783 call read_byte ; RECORD MARK
2788 call read_hexchar ; RECLEN
2790 call read_hexchar ; LOAD ADDR H
2792 call read_hexchar ; LOAD ADDR L
2797 call read_hexchar ; RECTYP
2799 call read_hexchar ; DATA
2808 call read_hexchar ; CHKSUM
2823 ;-------------------------------------------------------------------------------
2842 ;-------------------------------------------------------------------------------
2843 ; > Wstartaddr endaddr
2844 ; Write a file to disk
2878 ld de,080h ; DMA_BUF
2907 ;-------------------------------------------------------------------------------
2909 ; Assemble Zilog Z180 mnemonics
2917 ;-------------------------------------------------------------------------------
2931 ;-------------------------------------------------------------------------------
2932 ; >>L [startaddr] [endaddr]
2933 ; List disassembled code
2967 ;-------------------------------------------------------------------------------
2995 ;-------------------------------------------------------------------------------
2998 ;-------------------------------------------------------------------------------
3002 ld (disas_argtype),a
3003 call disas_get_instrlen
3014 ld a,(disas_argtype)
3015 ld hl,(disas_arg_16)
3029 ld (isprefix_ixiy),a
3048 ld (isprefix_ixiy),a
3059 ;-------------------------------------------------------------------------------
3087 ;-------------------------------------------------------------------------------
3088 ; DD/FD 3 byte (ix+d)/(iy+d)
3135 ;-------------------------------------------------------------------------------
3157 ;-------------------------------------------------------------------------------
3162 ld a,(isprefix_ixiy)
3173 ;-------------------------------------------------------------------------------
3194 ;-------------------------------------------------------------------------------
3251 ;-------------------------------------------------------------------------------
3252 ; 1 byte opcodes (no parameters)
3253 ; Format: db opcode, t_MNEMONICS-index
3272 ; Format: db mask, match, t_MNEMONICS-index
3273 ; dw argument formating fuction
3275 db 0c0h,040h,056h ;ld r,r
3277 db 0f8h,080h,003h ;add a,r
3279 db 0f8h,088h,000h ;adc a,r
3281 db 0f8h,090h,0c9h ;sub r
3283 db 0f8h,098h,0b7h ;sbc a,r
3285 db 0f8h,0a0h,006h ;and r
3287 db 0f8h,0a8h,0cch ;xor r
3289 db 0f8h,0b0h,06ch ;or r
3291 db 0f8h,0b8h,013h ;cp r
3293 db 0c7h,0c0h,08bh ;ret cc
3295 db 0c7h,0c7h,0b4h ;rst
3297 db 0ffh,0c9h,08bh ;ret
3299 db 0cfh,0c1h,081h ;pop rr
3301 db 0cfh,0c5h,084h ;push rr
3303 db 0ffh,0e3h,034h ;ex (sp),hl
3305 db 0ffh,0e9h,052h ;jp (hl)
3307 db 0ffh,0ebh,034h ;ex de,hl
3309 db 0ffh,0f9h,056h ;ld sp,hl
3311 db 0cfh,003h,041h ;inc rr
3313 db 0cfh,00bh,029h ;dec rr
3315 db 0c7h,004h,041h ;inc r
3317 db 0c7h,005h,029h ;dec r
3319 db 0ffh,008h,034h ;ex af,af'
3321 db 0cfh,009h,003h ;add hl,rr
3323 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
3325 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
3331 db 0c7h,006h,056h ;ld r,nn
3333 db 0ffh,0c6h,003h ;add a,nn
3335 db 0ffh,0ceh,000h ;adc a,nn
3337 db 0ffh,0d6h,0c9h ;sub a,nn
3339 db 0ffh,0deh,0b7h ;sbc a,nn
3341 db 0ffh,0e6h,006h ;and a,nn
3343 db 0ffh,0eeh,0cch ;xor nn
3345 db 0ffh,0f6h,06ch ;or nn
3347 db 0ffh,0feh,013h ;cp a,nn
3349 db 0ffh,010h,02eh ;djnz
3351 db 0ffh,018h,054h ;jr
3353 db 0e7h,020h,054h ;jr cc,
3355 db 0ffh,0d3h,076h ;out (nn),a
3357 db 0ffh,0dbh,03fh ;in a,(nn)
3363 db 0c7h,0c2h,052h ;jp cc,mn
3365 db 0c7h,0c4h,00ch ;call cc,mn
3367 db 0cfh,001h,056h ;ld ww,mn
3369 db 0ffh,0c3h,052h ;jp mn
3371 db 0ffh,0cdh,00ch ;call mn
3373 db 0ffh,022h,056h ;ld (mn),hl
3375 db 0ffh,02ah,056h ;ld hl,(mn)
3377 db 0ffh,032h,056h ;ld (mn),a
3379 db 0ffh,03ah,056h ;ld a,(mn)
3383 ; Prefix ED + 1 byte opcode, no arguments
3384 ; Format: opcode, t_MNEMONICS index
3415 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
3417 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
3419 db 0ffh,078h,03fh ;in r,(c) ;r=a
3421 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
3423 db 0f7h,061h,076h ;out (c),r ;r=h,l
3425 db 0ffh,079h,076h ;out (c),r ;r=a
3427 db 0cfh,042h,0b7h ;sbc hl,rr
3429 db 0cfh,04ah,000h ;adc hl,rr
3431 db 0ffh,046h,03dh ;im 0
3433 db 0ffh,056h,03dh ;im 1
3435 db 0ffh,05eh,03dh ;im 2
3437 db 0ffh,047h,056h ;ld i,a
3439 db 0ffh,057h,056h ;ld a,i
3441 db 0ffh,04fh,056h ;ld r,a
3443 db 0ffh,05fh,056h ;ld a,r
3445 db 0cfh,04ch,0d2h ;mlt rr
3447 db 0c7h,004h,0eeh ;tst r
3452 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
3454 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
3456 db 0ffh,038h,0cfh ;in0 a,(m)
3458 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
3460 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
3462 db 0ffh,039h,0e7h ;out0 (m),a
3464 db 0ffh,064h,0eeh ;tst m
3466 db 0ffh,074h,0f1h ;tstio m
3471 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
3473 db 0ffh,073h,056h ;ld (mn),sp
3475 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
3477 db 0ffh,07bh,056h ;ld sp,(mn)
3483 db 0f8h,000h,09bh ;rlc g
3485 db 0f8h,008h,0aah ;rrc g
3487 db 0f8h,010h,096h ;rl g
3489 db 0f8h,018h,0a5h ;rr g
3491 db 0f8h,020h,0c0h ;sla g
3493 db 0f8h,028h,0c3h ;sra g
3495 db 0f8h,038h,0c6h ;srl g
3497 db 0c0h,040h,009h ;bit b,g
3499 db 0c0h,080h,088h ;res b,g
3501 db 0c0h,0c0h,0bdh ;set b,g
3505 ;-------------------------------------------------------------------------------
3577 ld a,(isprefix_ixiy)
3627 ld (disas_argtype),a
3628 ld (disas_arg_16),hl
3737 ld a,(isprefix_ixiy)
3757 ld a,(isprefix_ixiy)
3779 ld a,(isprefix_ixiy)
3784 ld a,(isprefix_ixiy)
3814 ld a,(isprefix_ixiy)
3846 ;-------------------------------------------------------------------------------
3977 ;-------------------------------------------------------------------------------
3990 call disas_get_instrlen
4005 call c,bp_trace_enter
4010 ;-------------------------------------------------------------------------------
4013 db 0ffh,0ddh,000h ;Prefix DD
4015 db 0ffh,0fdh,000h ;Prefix FD
4017 db 0ffh,0edh,000h ;Prefix ED
4021 db 0ffh,0cdh,000h ;call mn
4023 db 0ffh,0c3h,000h ;jp mn
4025 db 0ffh,0e9h,000h ;jp ()
4027 db 0ffh,0c9h,000h ;ret
4029 db 0ffh,0cfh,000h ;rst 8
4031 db 0c7h,0c7h,000h ;rst n
4033 db 0c7h,0c4h,000h ;call cc,mn
4035 db 0f7h,010h,000h ;djnz d; jr d
4037 db 0e7h,020h,000h ;jr cc,d
4039 db 0c7h,0c2h,000h ;jp cc,mn
4041 db 0c7h,0c0h,000h ;ret cc
4045 ;-------------------------------------------------------------------------------
4046 ; call mn call cc,mn
4051 ld a,(trace_call_flag)
4090 cp 0e9h ; jp (ix); jp (iy)
4126 ld a,(trace_call_flag)
4154 ld a,(trace_call_flag)
4161 ;-------------------------------------------------------------------------------
4163 ; >>C[N][J] W expression
4164 ; >>C[N][J] U expression
4165 ; trace over Calls [No list] [Jumps only] /.While./.Until.
4171 ;-------------------------------------------------------------------------------
4173 ; >>T[N][J] W expression
4174 ; >>T[N][J] U expression
4175 ; Trace [no List] [Jumps only] / .While. / .Until.
4181 ld (trace_call_flag),a
4195 jr z,tc_save_uw_expr_ptr
4196 ld hl,1 ;default: 1 step
4197 call get_lastarg_def
4198 tc_save_uw_expr_ptr:
4199 ld (trace_cnt_or_ptr),hl
4201 ld (bp_p_cpu_flag),a
4207 call bp_clr_temporary
4218 ld a,(trace_UW_flag) ;0 or 'U' or 'W'
4220 jr z,tc_cnt ;flag is 0, check for step count.
4221 ld de,(trace_cnt_or_ptr)
4227 ld hl,trace_UW_flag ;'U' or 'W'
4229 bit 1,a ;'U' = 55H, 'W' = 57H
4231 do_break0: ;print registers and go to main loop
4235 ld hl,(trace_cnt_or_ptr)
4237 ld (trace_cnt_or_ptr),hl
4246 ld a,(bp_p_cpu_flag)
4248 ld (bp_p_cpu_flag),a
4255 ld (trace_UW_flag),a
4270 ld (trace_UW_flag),a
4290 ;-------------------------------------------------------------------------------
4295 ;-------------------------------------------------------------------------------
4300 db 0 ;1=call, 0=trace
4302 db 0 ;0 or 'U' or 'W'
4324 current_cseg defl $ - current_cseg
4325 .phase current_phase + current_cseg
4328 LD SP,ldr_end+(stack-ddtz_base)
4329 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
4342 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
4343 ld bc,0108h ;init bit counter
4347 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
4351 INC DE ;size rounded up to next page boundary
4354 SBC HL,DE ;BDOS - size
4355 LD (BDOS+1),HL ;-> new BDOS entry
4370 ld b,c ;reload bit counter
4371 LD e,(HL) ;get next 8 relocation bits
4397 LD HL,conbuf+2-ddtz_base
4401 current_phase defl $
4405 ds EXPR_BUF_SIZE - ($ - expr_buf)
4408 ;-------------------------------------------------------------------------------
4450 ddtz_size equ $-ddtz_base
4453 ;-------------------------------------------------------------------------------