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)
114 ;-------------------------------------------------------------------------------
149 ld hl,(1) ;wboot addr
167 ds CONBUF_SIZE + 3 - ($ - conbuf)
169 ;-------------------------------------------------------------------------------
171 ?const: jp 0 ; return console input status
172 ?conin: jp 0 ; return console input character
173 ?cono: jp 0 ; send console output character
174 ?list: jp 0 ; send list output character
175 ?auxo: jp 0 ; send auxiliary output character
176 ?auxi: jp 0 ; return auxiliary input character
179 dw ERROR ;cmd_@ ;examine/substitute the displacement register @
180 dw ERROR ;cmd_A ;Assemble
181 dw cmd_B ;Breakpoints display/set/clear
182 dw ERROR ;cmd_C ;trace over Calls
183 dw cmd_D ;Display memory in hex and ascii
185 dw ERROR ;cmd_F ;specify Filename and command line
187 dw cmd_H ;compute Hex and other expressions
188 dw cmd_I ;Input a byte from port
191 dw cmd_L ;List disassembled code
192 dw cmd_M ;Move memory [and verify]
194 dw cmd_O ;Output a byte to port
196 dw cmd_Q ;Qery memory for byte string
197 dw cmd_R ;Read binary or hex file
198 dw cmd_S ;Substitute memory
201 dw cmd_V ;Verify (compare) two memory areas
202 dw ERROR ;cmd_W ;Write a file to disk
203 dw cmd_X ;eXamine [and substitute] registers
204 dw ERROR ;cmd_Y ;examine [and substitute] Y variables
205 dw cmd_Z ;Zap (fill) memory with a byte string
215 call bp_clr_temporary
245 ;-------------------------------------------------------------------------------
265 defb 03eh ;ld a,.. swallow push hl
424 ;-------------------------------------------------------------------------------
431 ;-------------------------------------------------------------------------------
450 ;-------------------------------------------------------------------------------
475 ;-------------------------------------------------------------------------------
490 jr z,inl_e ;Accept line
492 jr z,inl_e ;Accept line
499 call DELC ;Delete Char
504 call DELL ;Delete Line
514 ld a,'^' ;Controll characters
535 ;-------------------------------------------------------------------------------
548 ;-------------------------------------------------------------------------------
561 ;-------------------------------------------------------------------------------
577 ;-------------------------------------------------------------------------------
584 ld de,stack-(STACK_SIZE-28)
591 ;-------------------------------------------------------------------------------
605 ;-------------------------------------------------------------------------------
715 defb 0e6h ;and a,.. clear carry
727 defb 03eh ;ld a,.. swallow pop af
769 jr z,error0 ;'S', but no expression following
773 ;-------------------------------------------------------------------------------
856 ; de: x (x shifted out, q shifted in)
858 ; hl: r (initially 0)
933 ;-------------------------------------------------------------------------------
975 ;-------------------------------------------------------------------------------
1061 ;-------------------------------------------------------------------------------
1169 ;-------------------------------------------------------------------------------
1216 ld hl,t_flag_names+7
1311 ;-------------------------------------------------------------------------------
1312 ; > G [startaddr] [;breakp..]
1313 ; Go [to start] [with temporary breakpoints]
1317 ld (bp_p_cpu_flag),a
1332 ;-------------------------------------------------------------------------------
1338 ld (pbl_loop_adr),hl
1351 ld hl,(pbl_loop_adr)
1365 ;-------------------------------------------------------------------------------
1367 ; display all breakpoints
1368 ; > B breakp [breakp..]
1371 ; clear all breakpoints
1372 ; > BX breakp [breakp..]
1375 ; breakp can be any valid expression
1435 ;-------------------------------------------------------------------------------
1436 ; Add break points to list
1437 ; A = 1 Permanent (B command)
1438 ; A = 2 Temporary (G command)
1455 call bp_get_freeslot
1477 ;-------------------------------------------------------------------------------
1478 ; Breakpoint handling routine.
1512 call inchar ;Keyboard hit?
1520 call bp_clr_temporary
1533 ld (bp_p_cpu_flag),a
1590 call bp_get_freeslot
1629 ;-------------------------------------------------------------------------------
1634 ld a,(bp_p_cpu_flag)
1664 ;-------------------------------------------------------------------------------
1666 ; examine all Y variables
1668 ; examine (and substitute) an Y variable
1671 ;-------------------------------------------------------------------------------
1673 ; eXamine (display) all cpu registers and
1674 ; the instruction at the current program counter
1676 ; eXamine (and substitute) a register
1885 ;-------------------------------------------------------------------------------
1891 call get_lastarg_def
1925 ;-------------------------------------------------------------------------------
1927 ; examine (substitute) displacement register @
1931 ;-------------------------------------------------------------------------------
1933 ; Input a byte from port
1938 call get_lastarg_def
1950 ;-------------------------------------------------------------------------------
1952 ; Output a byte to a port
1963 call get_lastarg_def
1971 ;-------------------------------------------------------------------------------
1972 ; > Vstartaddr endaddr targetaddr
1973 ; Verify (compare) two memory areas
2003 ;-------------------------------------------------------------------------------
2004 ; > M startaddr endaddr destaddr
2018 db 01h ;swallow ldir instruction (ld bc,...)
2023 ;-------------------------------------------------------------------------------
2025 ; display Highest load address of last filed loaded, Maximum "High"
2026 ; off all loaded files, and Top address of available memory
2028 ; evaluate expression and display result in hex, decimal and other formats
2048 ;-------------------------------------------------------------------------------
2049 ; > Q[J] startaddr endaddr bytes
2050 ; Query memory for a byte string [Justified]
2090 ;-------------------------------------------------------------------------------
2091 ; > Z startaddr endaddr bytes
2092 ; Zap (fill) memory with a byte string
2126 sub_0ef7h: ;from cmd_Q, cmd_Z
2127 db 0e6h ;and 037h (clear carry)
2128 sub_0ef8h: ;from cmd_S
2176 ;-------------------------------------------------------------------------------
2177 ; >>D [startaddr] [endaddr]
2178 ; Display memory in hex and ASCII
2246 ;-------------------------------------------------------------------------------
2248 ; specifiy filenames and command line
2252 ;-------------------------------------------------------------------------------
2253 ; > R [displacement]
2254 ; Read Intel Hex File from console [add displacement]
2258 call get_lastarg_def ;get offset from command line
2267 ld c,0 ;init checksum
2268 call i.gethexbyte ;record len
2270 call i.gethexbyte ;address high
2272 call i.gethexbyte ;address low
2274 call i.gethexbyte ;record type (ignored)
2276 and a ;record len == 0?
2287 djnz l16c6h ;repeat for record len
2288 call i.gethexbyte ;checksum
2291 jp nz,ERROR ;exit if checksum error
2292 jr w_recstart ;next record
2329 ld de,TPA ;lowest allowed load address
2332 ld de,(BDOS+1) ;highest allowed load address
2347 ld (hl),a ;store byte
2350 ;-------------------------------------------------------------------------------
2369 ;-------------------------------------------------------------------------------
2370 ; > Wstartaddr endaddr
2371 ; Write a file to disk
2375 ;-------------------------------------------------------------------------------
2377 ; Assemble Zilog Z180 mnemonics
2386 ;-------------------------------------------------------------------------------
2387 ; >>L [startaddr] [endaddr]
2388 ; List disassembled code
2422 ;-------------------------------------------------------------------------------
2445 ;-------------------------------------------------------------------------------
2449 ld (disas_argtype),a
2450 call disas_get_instrlen
2461 ld a,(disas_argtype)
2462 ld hl,(disas_arg_16)
2476 ld (isprefix_ixiy),a
2495 ld (isprefix_ixiy),a
2506 ;-------------------------------------------------------------------------------
2534 ;-------------------------------------------------------------------------------
2535 ; DD/FD 3 byte (ix+d)/(iy+d)
2582 ;-------------------------------------------------------------------------------
2604 ;-------------------------------------------------------------------------------
2609 ld a,(isprefix_ixiy)
2620 ;-------------------------------------------------------------------------------
2640 ;-------------------------------------------------------------------------------
2697 ;-------------------------------------------------------------------------------
2698 ; 1 byte opcodes (no parameters)
2699 ; Format: db opcode, t_MNEMONICS-index
2719 ; Format: db mask, match, t_MNEMONICS-index
2720 ; dw argument formating fuction
2722 db 0c0h,040h,056h ;ld r,r
2724 db 0f8h,080h,003h ;add a,r
2726 db 0f8h,088h,000h ;adc a,r
2728 db 0f8h,090h,0c9h ;sub r
2730 db 0f8h,098h,0b7h ;sbc a,r
2732 db 0f8h,0a0h,006h ;and r
2734 db 0f8h,0a8h,0cch ;xor r
2736 db 0f8h,0b0h,06ch ;or r
2738 db 0f8h,0b8h,013h ;cp r
2740 db 0c7h,0c0h,08bh ;ret cc
2742 db 0c7h,0c7h,0b4h ;rst
2744 db 0cfh,0c1h,081h ;pop rr
2746 db 0cfh,0c5h,084h ;push rr
2748 db 0ffh,0e3h,034h ;ex (sp),hl
2750 db 0ffh,0e9h,052h ;jp (hl)
2752 db 0ffh,0ebh,034h ;ex de,hl
2754 db 0ffh,0f9h,056h ;ld sp,hl
2756 db 0cfh,003h,041h ;inc rr
2758 db 0cfh,00bh,029h ;dec rr
2760 db 0c7h,004h,041h ;inc r
2762 db 0c7h,005h,029h ;dec r
2764 db 0ffh,008h,034h ;ex af,af'
2766 db 0cfh,009h,003h ;add hl,rr
2768 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
2770 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
2776 db 0c7h,006h,056h ;ld r,nn
2778 db 0ffh,0c6h,003h ;add a,nn
2780 db 0ffh,0ceh,000h ;adc a,nn
2782 db 0ffh,0d6h,0c9h ;sub nn
2784 db 0ffh,0deh,0b7h ;sbc a,nn
2786 db 0ffh,0e6h,006h ;and nn
2788 db 0ffh,0eeh,0cch ;xor nn
2790 db 0ffh,0f6h,06ch ;or nn
2792 db 0ffh,0feh,013h ;cp nn
2794 db 0ffh,010h,02eh ;djnz
2796 db 0ffh,018h,054h ;jr
2798 db 0e7h,020h,054h ;jr cc,
2800 db 0ffh,0d3h,076h ;out (nn),a
2802 db 0ffh,0dbh,03fh ;in a,(nn)
2808 db 0c7h,0c2h,052h ;jp cc,mn
2810 db 0c7h,0c4h,00ch ;call cc,mn
2812 db 0cfh,001h,056h ;ld ww,mn
2814 db 0ffh,0c3h,052h ;jp mn
2816 db 0ffh,0cdh,00ch ;call mn
2818 db 0ffh,022h,056h ;ld (mn),hl
2820 db 0ffh,02ah,056h ;ld hl,(mn)
2822 db 0ffh,032h,056h ;ld (mn),a
2824 db 0ffh,03ah,056h ;ld a,(mn)
2828 ; Prefix ED + 1 byte opcode, no arguments
2829 ; Format: opcode, t_MNEMONICS index
2860 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
2862 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
2864 db 0ffh,078h,03fh ;in r,(c) ;r=a
2866 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
2868 db 0f7h,061h,076h ;out (c),r ;r=h,l
2870 db 0ffh,079h,076h ;out (c),r ;r=a
2872 db 0cfh,042h,0b7h ;sbc hl,rr
2874 db 0cfh,04ah,000h ;adc hl,rr
2876 db 0ffh,046h,03dh ;im 0
2878 db 0ffh,056h,03dh ;im 1
2880 db 0ffh,05eh,03dh ;im 2
2882 db 0e7h,047h,056h ;ld i,a ... ld a,r
2884 db 0cfh,04ch,0d2h ;mlt rr
2886 db 0c7h,004h,0eeh ;tst r
2891 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
2893 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
2895 db 0ffh,038h,0cfh ;in0 a,(m)
2897 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
2899 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
2901 db 0ffh,039h,0e7h ;out0 (m),a
2903 db 0ffh,064h,0eeh ;tst m
2905 db 0ffh,074h,0f1h ;tstio m
2910 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
2912 db 0ffh,073h,056h ;ld (mn),sp
2914 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
2916 db 0ffh,07bh,056h ;ld sp,(mn)
2922 db 0f8h,000h,09bh ;rlc g
2924 db 0f8h,008h,0aah ;rrc g
2926 db 0f8h,010h,096h ;rl g
2928 db 0f8h,018h,0a5h ;rr g
2930 db 0f8h,020h,0c0h ;sla g
2932 db 0f8h,028h,0c3h ;sra g
2934 db 0f8h,038h,0c6h ;srl g
2936 db 0c0h,040h,009h ;bit b,g
2938 db 0c0h,080h,088h ;res b,g
2940 db 0c0h,0c0h,0bdh ;set b,g
2944 ;-------------------------------------------------------------------------------
3017 ld a,(isprefix_ixiy)
3067 ld (disas_argtype),a
3068 ld (disas_arg_16),hl
3170 ld a,(isprefix_ixiy)
3190 ld a,(isprefix_ixiy)
3214 ld a,(isprefix_ixiy)
3239 ld a,(isprefix_ixiy)
3271 ;-------------------------------------------------------------------------------
3394 ;-------------------------------------------------------------------------------
3404 ld hl,l20edh ;set break after BDOS call
3407 call disas_get_instrlen
3422 call c,bp_trace_enter
3427 ;-------------------------------------------------------------------------------
3430 db 0ffh,0ddh,000h ;Prefix DD
3432 db 0ffh,0fdh,000h ;Prefix FD
3434 db 0ffh,0edh,000h ;Prefix ED
3437 db 0ffh,0cdh,000h ;call mn
3439 db 0ffh,0c3h,000h ;jp mn
3441 db 0ffh,0e9h,000h ;jp ()
3443 db 0ffh,0c9h,000h ;ret
3445 db 0ffh,0cfh,000h ;rst 8
3447 db 0c7h,0c7h,000h ;rst n
3449 db 0c7h,0c4h,000h ;call cc,mn
3451 db 0f7h,010h,000h ;djnz d; jr d
3453 db 0e7h,020h,000h ;jr cc,d
3455 db 0c7h,0c2h,000h ;jp cc,mn
3457 db 0c7h,0c0h,000h ;ret cc
3461 ;-------------------------------------------------------------------------------
3462 ; call mn call cc,mn
3500 cp 0e9h ; jp (ix); jp (iy)
3534 ld hl,(reg_sp) ;break on return address
3559 ;-------------------------------------------------------------------------------
3561 ; >>C[N][J] W expression
3562 ; >>C[N][J] U expression
3563 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3566 ;-------------------------------------------------------------------------------
3568 ; >>T[N][J] W expression
3569 ; >>T[N][J] U expression
3570 ; Trace [no List] [Jumps only] / .While. / .Until.
3574 ld hl,1 ;default: 1 step
3575 call get_lastarg_def
3576 ld (trace_cnt_or_ptr),hl
3578 ld (bp_p_cpu_flag),a
3583 call bp_clr_temporary
3584 ld hl,(trace_cnt_or_ptr)
3586 ld (trace_cnt_or_ptr),hl
3594 ld (bp_p_cpu_flag),a
3598 ;-------------------------------------------------------------------------------
3603 ;-------------------------------------------------------------------------------
3621 current_cseg defl $ - current_cseg
3622 .phase current_phase + current_cseg
3625 LD SP,ldr_end+(stack-ddtz_base)
3626 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
3639 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
3640 ld bc,0108h ;init bit counter
3644 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
3648 INC DE ;size rounded up to next page boundary
3651 SBC HL,DE ;BDOS - size
3652 LD (BDOS+1),HL ;-> new BDOS entry
3667 ld b,c ;reload bit counter
3668 LD e,(HL) ;get next 8 relocation bits
3694 LD HL,conbuf+2-ddtz_base
3698 current_phase defl $
3702 ds EXPR_BUF_SIZE - ($ - expr_buf)
3705 ;-------------------------------------------------------------------------------
3738 ddtz_size equ $-ddtz_base
3741 ;-------------------------------------------------------------------------------