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)
127 ;-------------------------------------------------------------------------------
169 ds CONBUF_SIZE + 3 - ($ - conbuf)
171 ;-------------------------------------------------------------------------------
174 dw cmd_@ ;examine/substitute the displacement register @
175 dw ERROR ;cmd_A ;Assemble
176 dw cmd_B ;Breakpoints display/set/clear
177 dw cmd_C ;trace over Calls
178 dw cmd_D ;Display memory in hex and ascii
180 dw cmd_F ;specify Filename and command line
182 dw cmd_H ;compute Hex and other expressions
183 dw cmd_I ;Input a byte from port
186 dw cmd_L ;List disassembled code
187 dw cmd_M ;Move memory [and verify]
189 dw cmd_O ;Output a byte to port
191 dw cmd_Q ;Qery memory for byte string
192 dw cmd_R ;Read binary or hex file
193 dw cmd_S ;Substitute memory
196 dw cmd_V ;Verify (compare) two memory areas
197 dw cmd_W ;Write a file to disk
198 dw cmd_X ;eXamine [and substitute] registers
199 dw ERROR ;cmd_Y ;examine [and substitute] Y variables
200 dw cmd_Z ;Zap (fill) memory with a byte string
211 call bp_clr_temporary
241 ;-------------------------------------------------------------------------------
280 defb 03eh ;ld a,.. swallow push hl
433 ;-------------------------------------------------------------------------------
471 ;-------------------------------------------------------------------------------
484 ;-------------------------------------------------------------------------------
510 ;-------------------------------------------------------------------------------
517 ld de,stack-(STACK_SIZE-28)
524 ;-------------------------------------------------------------------------------
538 ;-------------------------------------------------------------------------------
664 defb 0e6h ;and a,.. clear carry
676 defb 03eh ;ld a,.. swallow pop af
718 jr z,error0 ;'S', but no expression following
722 ;-------------------------------------------------------------------------------
743 ;-------------------------------------------------------------------------------
788 ld hl,tab_func_eqlege
890 ; de: x (x shifted out, q shifted in)
892 ; hl: r (initially 0)
967 ;-------------------------------------------------------------------------------
1013 jr z,fact_factstring
1018 ;-------------------------------------------------------------------------------
1104 ;-------------------------------------------------------------------------------
1212 ;-------------------------------------------------------------------------------
1260 ld hl,t_flag_names+7
1361 ;-------------------------------------------------------------------------------
1362 ; > G [startaddr] [;breakp..]
1363 ; Go [to start] [with temporary breakpoints]
1367 ld (trace_call_flag),a
1368 ld (bp_p_cpu_flag),a
1383 ;-------------------------------------------------------------------------------
1389 ld (pbl_loop_adr),hl
1402 ld hl,(pbl_loop_adr)
1412 call bp_clr_condition
1417 ;-------------------------------------------------------------------------------
1419 ; display all breakpoints
1420 ; > B breakp [breakp..]
1423 ; clear all breakpoints
1424 ; > BX address [address..]
1428 ; [R] expression [I condition]
1465 call bp_clr_condition
1506 ;-------------------------------------------------------------------------------
1507 ; Add break points to list
1508 ; A = 1 Permanent (B command)
1509 ; A = 2 Temporary (G command)
1530 call bp_get_freeslot
1537 call bp_get_condition
1594 ld (hl),c ; trailing 0
1600 ;-------------------------------------------------------------------------------
1601 ; Breakpoint handling routine.
1635 call inchar ;Keyboard hit?
1643 call bp_clr_temporary
1656 ld (bp_p_cpu_flag),a
1700 ld (bp_p_cpu_flag),a
1745 call bp_get_freeslot
1788 ;-------------------------------------------------------------------------------
1793 ld a,(bp_p_cpu_flag)
1823 ;-------------------------------------------------------------------------------
1877 ;-------------------------------------------------------------------------------
1879 ; examine all Y variables
1881 ; examine (and substitute) an Y variable
1884 ;-------------------------------------------------------------------------------
1886 ; eXamine (display) all cpu registers and
1887 ; the instruction at the current program counter
1889 ; eXamine (and substitute) a register
2119 ;-------------------------------------------------------------------------------
2125 call get_lastarg_def
2159 ;-------------------------------------------------------------------------------
2161 ; examine (substitute) displacement register @
2173 ;-------------------------------------------------------------------------------
2175 ; Input a byte from port
2181 call get_lastarg_def
2193 ;-------------------------------------------------------------------------------
2195 ; Output a byte to a port
2207 call get_lastarg_def
2215 ;-------------------------------------------------------------------------------
2216 ; > Vstartaddr endaddr targetaddr
2217 ; Verify (compare) two memory areas
2250 ;-------------------------------------------------------------------------------
2251 ; > M[V] startaddr endaddr destaddr
2252 ; Move memory [and verify]
2274 db 01h ;swallow ldir instruction (ld bc,...)
2284 ;-------------------------------------------------------------------------------
2286 ; display Highest load address of last filed loaded, Maximum "High"
2287 ; off all loaded files, and Top address of available memory
2289 ; evaluate expression and display result in hex, decimal and other formats
2290 ; > H expression expression
2291 ; display sum und difference of expressions
2328 ;-------------------------------------------------------------------------------
2329 ; > Q[J] startaddr endaddr bytes
2330 ; Query memory for a byte string [Justified]
2371 ;-------------------------------------------------------------------------------
2372 ; > Z startaddr endaddr bytes
2373 ; Zap (fill) memory with a byte string
2425 db 0e6h ; and 037h (clear carry)
2488 ;-------------------------------------------------------------------------------
2489 ; >>D [startaddr] [endaddr]
2490 ; Display memory in hex and ASCII
2560 ;-------------------------------------------------------------------------------
2562 ; specifiy filenames and command line
2685 ;-------------------------------------------------------------------------------
2703 ;-------------------------------------------------------------------------------
2812 ;-------------------------------------------------------------------------------
2813 ; > R [displacement]
2814 ; Read a binary or hex file [add displacement]
2818 call get_lastarg_def
2854 call read_byte ; RECORD MARK
2859 call read_hexchar ; RECLEN
2861 call read_hexchar ; LOAD ADDR H
2863 call read_hexchar ; LOAD ADDR L
2868 call read_hexchar ; RECTYP
2870 call read_hexchar ; DATA
2879 call read_hexchar ; CHKSUM
2894 ;-------------------------------------------------------------------------------
2913 ;-------------------------------------------------------------------------------
2914 ; > Wstartaddr endaddr
2915 ; Write a file to disk
2949 ld de,080h ; DMA_BUF
2978 ;-------------------------------------------------------------------------------
2980 ; Assemble Zilog Z180 mnemonics
2988 ;-------------------------------------------------------------------------------
3002 ;-------------------------------------------------------------------------------
3003 ; >>L [startaddr] [endaddr]
3004 ; List disassembled code
3039 ;-------------------------------------------------------------------------------
3067 ;-------------------------------------------------------------------------------
3082 ;-------------------------------------------------------------------------------
3086 ld (disas_argtype),a
3087 call disas_get_instrlen
3098 ld a,(disas_argtype)
3099 ld hl,(disas_arg_16)
3113 ld (isprefix_ixiy),a
3132 ld (isprefix_ixiy),a
3143 ;-------------------------------------------------------------------------------
3171 ;-------------------------------------------------------------------------------
3172 ; DD/FD 3 byte (ix+d)/(iy+d)
3219 ;-------------------------------------------------------------------------------
3241 ;-------------------------------------------------------------------------------
3246 ld a,(isprefix_ixiy)
3257 ;-------------------------------------------------------------------------------
3278 ;-------------------------------------------------------------------------------
3335 ;-------------------------------------------------------------------------------
3336 ; 1 byte opcodes (no parameters)
3337 ; Format: db opcode, t_MNEMONICS-index
3356 ; Format: db mask, match, t_MNEMONICS-index
3357 ; dw argument formating fuction
3359 db 0c0h,040h,056h ;ld r,r
3361 db 0f8h,080h,003h ;add a,r
3363 db 0f8h,088h,000h ;adc a,r
3365 db 0f8h,090h,0c9h ;sub r
3367 db 0f8h,098h,0b7h ;sbc a,r
3369 db 0f8h,0a0h,006h ;and r
3371 db 0f8h,0a8h,0cch ;xor r
3373 db 0f8h,0b0h,06ch ;or r
3375 db 0f8h,0b8h,013h ;cp r
3377 db 0c7h,0c0h,08bh ;ret cc
3379 db 0c7h,0c7h,0b4h ;rst
3381 db 0ffh,0c9h,08bh ;ret
3383 db 0cfh,0c1h,081h ;pop rr
3385 db 0cfh,0c5h,084h ;push rr
3387 db 0ffh,0e3h,034h ;ex (sp),hl
3389 db 0ffh,0e9h,052h ;jp (hl)
3391 db 0ffh,0ebh,034h ;ex de,hl
3393 db 0ffh,0f9h,056h ;ld sp,hl
3395 db 0cfh,003h,041h ;inc rr
3397 db 0cfh,00bh,029h ;dec rr
3399 db 0c7h,004h,041h ;inc r
3401 db 0c7h,005h,029h ;dec r
3403 db 0ffh,008h,034h ;ex af,af'
3405 db 0cfh,009h,003h ;add hl,rr
3407 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
3409 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
3415 db 0c7h,006h,056h ;ld r,nn
3417 db 0ffh,0c6h,003h ;add a,nn
3419 db 0ffh,0ceh,000h ;adc a,nn
3421 db 0ffh,0d6h,0c9h ;sub a,nn
3423 db 0ffh,0deh,0b7h ;sbc a,nn
3425 db 0ffh,0e6h,006h ;and a,nn
3427 db 0ffh,0eeh,0cch ;xor nn
3429 db 0ffh,0f6h,06ch ;or nn
3431 db 0ffh,0feh,013h ;cp a,nn
3433 db 0ffh,010h,02eh ;djnz
3435 db 0ffh,018h,054h ;jr
3437 db 0e7h,020h,054h ;jr cc,
3439 db 0ffh,0d3h,076h ;out (nn),a
3441 db 0ffh,0dbh,03fh ;in a,(nn)
3447 db 0c7h,0c2h,052h ;jp cc,mn
3449 db 0c7h,0c4h,00ch ;call cc,mn
3451 db 0cfh,001h,056h ;ld ww,mn
3453 db 0ffh,0c3h,052h ;jp mn
3455 db 0ffh,0cdh,00ch ;call mn
3457 db 0ffh,022h,056h ;ld (mn),hl
3459 db 0ffh,02ah,056h ;ld hl,(mn)
3461 db 0ffh,032h,056h ;ld (mn),a
3463 db 0ffh,03ah,056h ;ld a,(mn)
3467 ; Prefix ED + 1 byte opcode, no arguments
3468 ; Format: opcode, t_MNEMONICS index
3499 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
3501 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
3503 db 0ffh,078h,03fh ;in r,(c) ;r=a
3505 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
3507 db 0f7h,061h,076h ;out (c),r ;r=h,l
3509 db 0ffh,079h,076h ;out (c),r ;r=a
3511 db 0cfh,042h,0b7h ;sbc hl,rr
3513 db 0cfh,04ah,000h ;adc hl,rr
3515 db 0ffh,046h,03dh ;im 0
3517 db 0ffh,056h,03dh ;im 1
3519 db 0ffh,05eh,03dh ;im 2
3521 db 0ffh,047h,056h ;ld i,a
3523 db 0ffh,057h,056h ;ld a,i
3525 db 0ffh,04fh,056h ;ld r,a
3527 db 0ffh,05fh,056h ;ld a,r
3529 db 0cfh,04ch,0d2h ;mlt rr
3531 db 0c7h,004h,0eeh ;tst r
3536 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
3538 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
3540 db 0ffh,038h,0cfh ;in0 a,(m)
3542 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
3544 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
3546 db 0ffh,039h,0e7h ;out0 (m),a
3548 db 0ffh,064h,0eeh ;tst m
3550 db 0ffh,074h,0f1h ;tstio m
3555 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
3557 db 0ffh,073h,056h ;ld (mn),sp
3559 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
3561 db 0ffh,07bh,056h ;ld sp,(mn)
3567 db 0f8h,000h,09bh ;rlc g
3569 db 0f8h,008h,0aah ;rrc g
3571 db 0f8h,010h,096h ;rl g
3573 db 0f8h,018h,0a5h ;rr g
3575 db 0f8h,020h,0c0h ;sla g
3577 db 0f8h,028h,0c3h ;sra g
3579 db 0f8h,038h,0c6h ;srl g
3581 db 0c0h,040h,009h ;bit b,g
3583 db 0c0h,080h,088h ;res b,g
3585 db 0c0h,0c0h,0bdh ;set b,g
3589 ;-------------------------------------------------------------------------------
3661 ld a,(isprefix_ixiy)
3711 ld (disas_argtype),a
3712 ld (disas_arg_16),hl
3821 ld a,(isprefix_ixiy)
3841 ld a,(isprefix_ixiy)
3863 ld a,(isprefix_ixiy)
3868 ld a,(isprefix_ixiy)
3898 ld a,(isprefix_ixiy)
3930 ;-------------------------------------------------------------------------------
4061 ;-------------------------------------------------------------------------------
4074 call disas_get_instrlen
4089 call c,bp_trace_enter
4094 ;-------------------------------------------------------------------------------
4097 db 0ffh,0ddh,000h ;Prefix DD
4099 db 0ffh,0fdh,000h ;Prefix FD
4101 db 0ffh,0edh,000h ;Prefix ED
4105 db 0ffh,0cdh,000h ;call mn
4107 db 0ffh,0c3h,000h ;jp mn
4109 db 0ffh,0e9h,000h ;jp ()
4111 db 0ffh,0c9h,000h ;ret
4113 db 0ffh,0cfh,000h ;rst 8
4115 db 0c7h,0c7h,000h ;rst n
4117 db 0c7h,0c4h,000h ;call cc,mn
4119 db 0f7h,010h,000h ;djnz d; jr d
4121 db 0e7h,020h,000h ;jr cc,d
4123 db 0c7h,0c2h,000h ;jp cc,mn
4125 db 0c7h,0c0h,000h ;ret cc
4129 ;-------------------------------------------------------------------------------
4130 ; call mn call cc,mn
4135 ld a,(trace_call_flag)
4174 cp 0e9h ; jp (ix); jp (iy)
4210 ld a,(trace_call_flag)
4238 ld a,(trace_call_flag)
4245 ;-------------------------------------------------------------------------------
4247 ; >>C[N][J] W expression
4248 ; >>C[N][J] U expression
4249 ; trace over Calls [No list] [Jumps only] /.While./.Until.
4256 ;-------------------------------------------------------------------------------
4258 ; >>T[N][J] W expression
4259 ; >>T[N][J] U expression
4260 ; Trace [no List] [Jumps only] / .While. / .Until.
4267 ld (trace_call_flag),a
4281 jr z,tc_save_uw_expr_ptr
4282 ld hl,1 ;default: 1 step
4283 call get_lastarg_def
4284 tc_save_uw_expr_ptr:
4285 ld (trace_cnt_or_ptr),hl
4287 ld (bp_p_cpu_flag),a
4293 call bp_clr_temporary
4304 ld a,(trace_UW_flag) ;0 or 'U' or 'W'
4306 jr z,tc_cnt ;flag is 0, check for step count.
4307 ld de,(trace_cnt_or_ptr)
4313 ld hl,trace_UW_flag ;'U' or 'W'
4315 bit 1,a ;'U' = 55H, 'W' = 57H
4317 do_break0: ;print registers and go to main loop
4321 ld hl,(trace_cnt_or_ptr)
4323 ld (trace_cnt_or_ptr),hl
4332 ld a,(bp_p_cpu_flag)
4334 ld (bp_p_cpu_flag),a
4341 ld (trace_UW_flag),a
4356 ld (trace_UW_flag),a
4376 ;-------------------------------------------------------------------------------
4381 ;-------------------------------------------------------------------------------
4386 db 0 ;1=call, 0=trace
4388 db 0 ;0 or 'U' or 'W'
4410 current_cseg defl $ - current_cseg
4411 .phase current_phase + current_cseg
4414 LD SP,ldr_end+(stack-ddtz_base)
4415 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
4428 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
4429 ld bc,0108h ;init bit counter
4433 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
4437 INC DE ;size rounded up to next page boundary
4440 SBC HL,DE ;BDOS - size
4441 LD (BDOS+1),HL ;-> new BDOS entry
4456 ld b,c ;reload bit counter
4457 LD e,(HL) ;get next 8 relocation bits
4483 LD HL,conbuf+2-ddtz_base
4487 current_phase defl $
4491 ds EXPR_BUF_SIZE - ($ - expr_buf)
4494 ;-------------------------------------------------------------------------------
4536 ddtz_size equ $-ddtz_base
4539 ;-------------------------------------------------------------------------------