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 ;-------------------------------------------------------------------------------
858 ; de: x (x shifted out, q shifted in)
860 ; hl: r (initially 0)
935 ;-------------------------------------------------------------------------------
983 ;-------------------------------------------------------------------------------
1069 ;-------------------------------------------------------------------------------
1177 ;-------------------------------------------------------------------------------
1224 ld hl,t_flag_names+7
1319 ;-------------------------------------------------------------------------------
1320 ; > G [startaddr] [;breakp..]
1321 ; Go [to start] [with temporary breakpoints]
1325 ld (bp_p_cpu_flag),a
1340 ;-------------------------------------------------------------------------------
1346 ld (pbl_loop_adr),hl
1359 ld hl,(pbl_loop_adr)
1373 ;-------------------------------------------------------------------------------
1375 ; display all breakpoints
1376 ; > B breakp [breakp..]
1379 ; clear all breakpoints
1380 ; > BX breakp [breakp..]
1383 ; breakp can be any valid expression
1443 ;-------------------------------------------------------------------------------
1444 ; Add break points to list
1445 ; A = 1 Permanent (B command)
1446 ; A = 2 Temporary (G command)
1463 call bp_get_freeslot
1485 ;-------------------------------------------------------------------------------
1486 ; Breakpoint handling routine.
1520 call inchar ;Keyboard hit?
1528 call bp_clr_temporary
1541 ld (bp_p_cpu_flag),a
1598 call bp_get_freeslot
1637 ;-------------------------------------------------------------------------------
1642 ld a,(bp_p_cpu_flag)
1672 ;-------------------------------------------------------------------------------
1674 ; examine all Y variables
1676 ; examine (and substitute) an Y variable
1679 ;-------------------------------------------------------------------------------
1681 ; eXamine (display) all cpu registers and
1682 ; the instruction at the current program counter
1684 ; eXamine (and substitute) a register
1911 ;-------------------------------------------------------------------------------
1917 call get_lastarg_def
1951 ;-------------------------------------------------------------------------------
1953 ; examine (substitute) displacement register @
1957 ;-------------------------------------------------------------------------------
1959 ; Input a byte from port
1964 call get_lastarg_def
1976 ;-------------------------------------------------------------------------------
1978 ; Output a byte to a port
1989 call get_lastarg_def
1997 ;-------------------------------------------------------------------------------
1998 ; > Vstartaddr endaddr targetaddr
1999 ; Verify (compare) two memory areas
2029 ;-------------------------------------------------------------------------------
2030 ; > M startaddr endaddr destaddr
2044 db 01h ;swallow ldir instruction (ld bc,...)
2049 ;-------------------------------------------------------------------------------
2051 ; display Highest load address of last filed loaded, Maximum "High"
2052 ; off all loaded files, and Top address of available memory
2054 ; evaluate expression and display result in hex, decimal and other formats
2074 ;-------------------------------------------------------------------------------
2075 ; > Q[J] startaddr endaddr bytes
2076 ; Query memory for a byte string [Justified]
2116 ;-------------------------------------------------------------------------------
2117 ; > Z startaddr endaddr bytes
2118 ; Zap (fill) memory with a byte string
2152 sub_0ef7h: ;from cmd_Q, cmd_Z
2153 db 0e6h ;and 037h (clear carry)
2154 sub_0ef8h: ;from cmd_S
2202 ;-------------------------------------------------------------------------------
2203 ; >>D [startaddr] [endaddr]
2204 ; Display memory in hex and ASCII
2272 ;-------------------------------------------------------------------------------
2274 ; specifiy filenames and command line
2278 ;-------------------------------------------------------------------------------
2279 ; > R [displacement]
2280 ; Read Intel Hex File from console [add displacement]
2284 call get_lastarg_def ;get offset from command line
2293 ld c,0 ;init checksum
2294 call i.gethexbyte ;record len
2296 call i.gethexbyte ;address high
2298 call i.gethexbyte ;address low
2300 call i.gethexbyte ;record type (ignored)
2302 and a ;record len == 0?
2313 djnz l16c6h ;repeat for record len
2314 call i.gethexbyte ;checksum
2317 jp nz,ERROR ;exit if checksum error
2318 jr w_recstart ;next record
2355 ld de,TPA ;lowest allowed load address
2358 ld de,(BDOS+1) ;highest allowed load address
2373 ld (hl),a ;store byte
2376 ;-------------------------------------------------------------------------------
2395 ;-------------------------------------------------------------------------------
2396 ; > Wstartaddr endaddr
2397 ; Write a file to disk
2401 ;-------------------------------------------------------------------------------
2403 ; Assemble Zilog Z180 mnemonics
2411 ;-------------------------------------------------------------------------------
2425 ;-------------------------------------------------------------------------------
2426 ; >>L [startaddr] [endaddr]
2427 ; List disassembled code
2461 ;-------------------------------------------------------------------------------
2489 ;-------------------------------------------------------------------------------
2492 ;-------------------------------------------------------------------------------
2496 ld (disas_argtype),a
2497 call disas_get_instrlen
2508 ld a,(disas_argtype)
2509 ld hl,(disas_arg_16)
2523 ld (isprefix_ixiy),a
2542 ld (isprefix_ixiy),a
2553 ;-------------------------------------------------------------------------------
2581 ;-------------------------------------------------------------------------------
2582 ; DD/FD 3 byte (ix+d)/(iy+d)
2629 ;-------------------------------------------------------------------------------
2651 ;-------------------------------------------------------------------------------
2656 ld a,(isprefix_ixiy)
2667 ;-------------------------------------------------------------------------------
2688 ;-------------------------------------------------------------------------------
2745 ;-------------------------------------------------------------------------------
2746 ; 1 byte opcodes (no parameters)
2747 ; Format: db opcode, t_MNEMONICS-index
2766 ; Format: db mask, match, t_MNEMONICS-index
2767 ; dw argument formating fuction
2769 db 0c0h,040h,056h ;ld r,r
2771 db 0f8h,080h,003h ;add a,r
2773 db 0f8h,088h,000h ;adc a,r
2775 db 0f8h,090h,0c9h ;sub r
2777 db 0f8h,098h,0b7h ;sbc a,r
2779 db 0f8h,0a0h,006h ;and r
2781 db 0f8h,0a8h,0cch ;xor r
2783 db 0f8h,0b0h,06ch ;or r
2785 db 0f8h,0b8h,013h ;cp r
2787 db 0c7h,0c0h,08bh ;ret cc
2789 db 0c7h,0c7h,0b4h ;rst
2791 db 0ffh,0c9h,08bh ;ret
2793 db 0cfh,0c1h,081h ;pop rr
2795 db 0cfh,0c5h,084h ;push rr
2797 db 0ffh,0e3h,034h ;ex (sp),hl
2799 db 0ffh,0e9h,052h ;jp (hl)
2801 db 0ffh,0ebh,034h ;ex de,hl
2803 db 0ffh,0f9h,056h ;ld sp,hl
2805 db 0cfh,003h,041h ;inc rr
2807 db 0cfh,00bh,029h ;dec rr
2809 db 0c7h,004h,041h ;inc r
2811 db 0c7h,005h,029h ;dec r
2813 db 0ffh,008h,034h ;ex af,af'
2815 db 0cfh,009h,003h ;add hl,rr
2817 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
2819 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
2825 db 0c7h,006h,056h ;ld r,nn
2827 db 0ffh,0c6h,003h ;add a,nn
2829 db 0ffh,0ceh,000h ;adc a,nn
2831 db 0ffh,0d6h,0c9h ;sub a,nn
2833 db 0ffh,0deh,0b7h ;sbc a,nn
2835 db 0ffh,0e6h,006h ;and a,nn
2837 db 0ffh,0eeh,0cch ;xor nn
2839 db 0ffh,0f6h,06ch ;or nn
2841 db 0ffh,0feh,013h ;cp a,nn
2843 db 0ffh,010h,02eh ;djnz
2845 db 0ffh,018h,054h ;jr
2847 db 0e7h,020h,054h ;jr cc,
2849 db 0ffh,0d3h,076h ;out (nn),a
2851 db 0ffh,0dbh,03fh ;in a,(nn)
2857 db 0c7h,0c2h,052h ;jp cc,mn
2859 db 0c7h,0c4h,00ch ;call cc,mn
2861 db 0cfh,001h,056h ;ld ww,mn
2863 db 0ffh,0c3h,052h ;jp mn
2865 db 0ffh,0cdh,00ch ;call mn
2867 db 0ffh,022h,056h ;ld (mn),hl
2869 db 0ffh,02ah,056h ;ld hl,(mn)
2871 db 0ffh,032h,056h ;ld (mn),a
2873 db 0ffh,03ah,056h ;ld a,(mn)
2877 ; Prefix ED + 1 byte opcode, no arguments
2878 ; Format: opcode, t_MNEMONICS index
2909 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
2911 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
2913 db 0ffh,078h,03fh ;in r,(c) ;r=a
2915 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
2917 db 0f7h,061h,076h ;out (c),r ;r=h,l
2919 db 0ffh,079h,076h ;out (c),r ;r=a
2921 db 0cfh,042h,0b7h ;sbc hl,rr
2923 db 0cfh,04ah,000h ;adc hl,rr
2925 db 0ffh,046h,03dh ;im 0
2927 db 0ffh,056h,03dh ;im 1
2929 db 0ffh,05eh,03dh ;im 2
2931 db 0ffh,047h,056h ;ld i,a
2933 db 0ffh,057h,056h ;ld a,i
2935 db 0ffh,04fh,056h ;ld r,a
2937 db 0ffh,05fh,056h ;ld a,r
2939 db 0cfh,04ch,0d2h ;mlt rr
2941 db 0c7h,004h,0eeh ;tst r
2946 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
2948 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
2950 db 0ffh,038h,0cfh ;in0 a,(m)
2952 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
2954 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
2956 db 0ffh,039h,0e7h ;out0 (m),a
2958 db 0ffh,064h,0eeh ;tst m
2960 db 0ffh,074h,0f1h ;tstio m
2965 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
2967 db 0ffh,073h,056h ;ld (mn),sp
2969 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
2971 db 0ffh,07bh,056h ;ld sp,(mn)
2977 db 0f8h,000h,09bh ;rlc g
2979 db 0f8h,008h,0aah ;rrc g
2981 db 0f8h,010h,096h ;rl g
2983 db 0f8h,018h,0a5h ;rr g
2985 db 0f8h,020h,0c0h ;sla g
2987 db 0f8h,028h,0c3h ;sra g
2989 db 0f8h,038h,0c6h ;srl g
2991 db 0c0h,040h,009h ;bit b,g
2993 db 0c0h,080h,088h ;res b,g
2995 db 0c0h,0c0h,0bdh ;set b,g
2999 ;-------------------------------------------------------------------------------
3071 ld a,(isprefix_ixiy)
3121 ld (disas_argtype),a
3122 ld (disas_arg_16),hl
3231 ld a,(isprefix_ixiy)
3251 ld a,(isprefix_ixiy)
3273 ld a,(isprefix_ixiy)
3278 ld a,(isprefix_ixiy)
3308 ld a,(isprefix_ixiy)
3340 ;-------------------------------------------------------------------------------
3471 ;-------------------------------------------------------------------------------
3481 ld hl,l20edh ;set break after BDOS call
3484 call disas_get_instrlen
3499 call c,bp_trace_enter
3504 ;-------------------------------------------------------------------------------
3507 db 0ffh,0ddh,000h ;Prefix DD
3509 db 0ffh,0fdh,000h ;Prefix FD
3511 db 0ffh,0edh,000h ;Prefix ED
3515 db 0ffh,0cdh,000h ;call mn
3517 db 0ffh,0c3h,000h ;jp mn
3519 db 0ffh,0e9h,000h ;jp ()
3521 db 0ffh,0c9h,000h ;ret
3523 db 0ffh,0cfh,000h ;rst 8
3525 db 0c7h,0c7h,000h ;rst n
3527 db 0c7h,0c4h,000h ;call cc,mn
3529 db 0f7h,010h,000h ;djnz d; jr d
3531 db 0e7h,020h,000h ;jr cc,d
3533 db 0c7h,0c2h,000h ;jp cc,mn
3535 db 0c7h,0c0h,000h ;ret cc
3539 ;-------------------------------------------------------------------------------
3540 ; call mn call cc,mn
3578 cp 0e9h ; jp (ix); jp (iy)
3612 ld hl,(reg_sp) ;break on return address
3637 ;-------------------------------------------------------------------------------
3639 ; >>C[N][J] W expression
3640 ; >>C[N][J] U expression
3641 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3644 ;-------------------------------------------------------------------------------
3646 ; >>T[N][J] W expression
3647 ; >>T[N][J] U expression
3648 ; Trace [no List] [Jumps only] / .While. / .Until.
3652 ld hl,1 ;default: 1 step
3653 call get_lastarg_def
3654 ld (trace_cnt_or_ptr),hl
3656 ld (bp_p_cpu_flag),a
3661 call bp_clr_temporary
3662 ld hl,(trace_cnt_or_ptr)
3664 ld (trace_cnt_or_ptr),hl
3672 ld (bp_p_cpu_flag),a
3676 ;-------------------------------------------------------------------------------
3681 ;-------------------------------------------------------------------------------
3699 current_cseg defl $ - current_cseg
3700 .phase current_phase + current_cseg
3703 LD SP,ldr_end+(stack-ddtz_base)
3704 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
3717 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
3718 ld bc,0108h ;init bit counter
3722 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
3726 INC DE ;size rounded up to next page boundary
3729 SBC HL,DE ;BDOS - size
3730 LD (BDOS+1),HL ;-> new BDOS entry
3745 ld b,c ;reload bit counter
3746 LD e,(HL) ;get next 8 relocation bits
3772 LD HL,conbuf+2-ddtz_base
3776 current_phase defl $
3780 ds EXPR_BUF_SIZE - ($ - expr_buf)
3783 ;-------------------------------------------------------------------------------
3816 ddtz_size equ $-ddtz_base
3819 ;-------------------------------------------------------------------------------