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
214 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 ;-------------------------------------------------------------------------------
559 ;-------------------------------------------------------------------------------
575 ;-------------------------------------------------------------------------------
582 ld de,stack-(STACK_SIZE-28)
589 ;-------------------------------------------------------------------------------
603 ;-------------------------------------------------------------------------------
713 defb 0e6h ;and a,.. clear carry
725 defb 03eh ;ld a,.. swallow pop af
767 jr z,error0 ;'S', but no expression following
771 ;-------------------------------------------------------------------------------
854 ; de: x (x shifted out, q shifted in)
856 ; hl: r (initially 0)
931 ;-------------------------------------------------------------------------------
973 ;-------------------------------------------------------------------------------
1059 ;-------------------------------------------------------------------------------
1167 ;-------------------------------------------------------------------------------
1214 ld hl,t_flag_names+7
1309 ;-------------------------------------------------------------------------------
1310 ; > G [startaddr] [;breakp..]
1311 ; Go [to start] [with temporary breakpoints]
1315 ld (bp_p_cpu_flag),a
1330 ;-------------------------------------------------------------------------------
1336 ld (pbl_loop_adr),hl
1349 ld hl,(pbl_loop_adr)
1363 ;-------------------------------------------------------------------------------
1365 ; display all breakpoints
1366 ; > B breakp [breakp..]
1369 ; clear all breakpoints
1370 ; > BX breakp [breakp..]
1373 ; breakp can be any valid expression
1433 ;-------------------------------------------------------------------------------
1434 ; Add break points to list
1435 ; A = 1 Permanent (B command)
1436 ; A = 2 Temporary (G command)
1453 call bp_get_freeslot
1475 ;-------------------------------------------------------------------------------
1476 ; Breakpoint handling routine.
1510 call inchar ;Keyboard hit?
1518 call bp_clr_temporary
1531 ld (bp_p_cpu_flag),a
1588 call bp_get_freeslot
1627 ;-------------------------------------------------------------------------------
1632 ld a,(bp_p_cpu_flag)
1662 ;-------------------------------------------------------------------------------
1664 ; examine all Y variables
1666 ; examine (and substitute) an Y variable
1669 ;-------------------------------------------------------------------------------
1671 ; eXamine (display) all cpu registers and
1672 ; the instruction at the current program counter
1674 ; eXamine (and substitute) a register
1883 ;-------------------------------------------------------------------------------
1889 call get_lastarg_def
1923 ;-------------------------------------------------------------------------------
1925 ; examine (substitute) displacement register @
1929 ;-------------------------------------------------------------------------------
1931 ; Input a byte from port
1936 call get_lastarg_def
1948 ;-------------------------------------------------------------------------------
1950 ; Output a byte to a port
1961 call get_lastarg_def
1969 ;-------------------------------------------------------------------------------
1970 ; > Vstartaddr endaddr targetaddr
1971 ; Verify (compare) two memory areas
2001 ;-------------------------------------------------------------------------------
2002 ; > M startaddr endaddr destaddr
2016 db 01h ;swallow ldir instruction (ld bc,...)
2021 ;-------------------------------------------------------------------------------
2023 ; display Highest load address of last filed loaded, Maximum "High"
2024 ; off all loaded files, and Top address of available memory
2026 ; evaluate expression and display result in hex, decimal and other formats
2046 ;-------------------------------------------------------------------------------
2047 ; > Q[J] startaddr endaddr bytes
2048 ; Query memory for a byte string [Justified]
2088 ;-------------------------------------------------------------------------------
2089 ; > Z startaddr endaddr bytes
2090 ; Zap (fill) memory with a byte string
2124 sub_0ef7h: ;from cmd_Q, cmd_Z
2125 db 0e6h ;and 037h (clear carry)
2126 sub_0ef8h: ;from cmd_S
2174 ;-------------------------------------------------------------------------------
2175 ; >>D [startaddr] [endaddr]
2176 ; Display memory in hex and ASCII
2244 ;-------------------------------------------------------------------------------
2246 ; specifiy filenames and command line
2250 ;-------------------------------------------------------------------------------
2251 ; > R [displacement]
2252 ; Read Intel Hex File from console [add displacement]
2256 call get_lastarg_def ;get offset from command line
2265 ld c,0 ;init checksum
2266 call i.gethexbyte ;record len
2268 call i.gethexbyte ;address high
2270 call i.gethexbyte ;address low
2272 call i.gethexbyte ;record type (ignored)
2274 and a ;record len == 0?
2285 djnz l16c6h ;repeat for record len
2286 call i.gethexbyte ;checksum
2289 jr nz,error2 ;exit if checksum error
2290 jr w_recstart ;next record
2328 ld de,TPA ;lowest allowed load address
2331 ld de,(BDOS+1) ;highest allowed load address
2346 ld (hl),a ;store byte
2349 ;-------------------------------------------------------------------------------
2368 ;-------------------------------------------------------------------------------
2369 ; > Wstartaddr endaddr
2370 ; Write a file to disk
2374 ;-------------------------------------------------------------------------------
2376 ; Assemble Zilog Z180 mnemonics
2380 ;-------------------------------------------------------------------------------
2381 ; >>L [startaddr] [endaddr]
2382 ; List disassembled code
2416 ;-------------------------------------------------------------------------------
2439 ;-------------------------------------------------------------------------------
2443 ld (disas_argtype),a
2444 call disas_get_instrlen
2450 call pstr ;print mnemonic
2453 call CALL_HL ;print arguments
2455 ld a,(disas_argtype)
2456 ld hl,(disas_arg_16)
2470 ld (isprefix_ixiy),a
2489 ld (isprefix_ixiy),a
2500 ;-------------------------------------------------------------------------------
2528 ;-------------------------------------------------------------------------------
2529 ; DD/FD 3 byte (ix+d)/(iy+d)
2576 ;-------------------------------------------------------------------------------
2598 ;-------------------------------------------------------------------------------
2603 ld a,(isprefix_ixiy)
2614 ;-------------------------------------------------------------------------------
2634 ;-------------------------------------------------------------------------------
2694 ;-------------------------------------------------------------------------------
2695 ; 1 byte opcodes (no parameters)
2696 ; Format: db opcode, t_MNEMONICS-index
2698 db 076h,o_HALT ;halt
2703 db 007h,o_RLCA ;rlca
2704 db 00fh,o_RRCA ;rrca
2716 ; Format: db mask, match, t_MNEMONICS-index
2717 ; dw argument formating function
2719 db 0c0h,040h,o_LD ;ld r[y],r[z]
2721 db 0f8h,080h,o_ADD ;add a,r[z]
2723 db 0f8h,088h,o_ADC ;adc a,r[z]
2725 db 0f8h,090h,o_SUB ;sub r[z]
2727 db 0f8h,098h,o_SBC ;sbc a,r[z]
2729 db 0f8h,0a0h,o_AND ;and r[z]
2731 db 0f8h,0a8h,o_XOR ;xor r[z]
2733 db 0f8h,0b0h,o_OR ;or r[z]
2735 db 0f8h,0b8h,o_CP ;cp r[z]
2737 db 0c7h,0c0h,o_RET ;ret cc
2739 db 0c7h,0c7h,o_RST ;rst
2741 db 0cfh,0c1h,o_POP ;pop rr
2743 db 0cfh,0c5h,o_PUSH ;push rr
2745 db 0ffh,0e3h,o_EX ;ex (sp),hl
2747 db 0ffh,0e9h,o_JP ;jp (hl)
2749 db 0ffh,0ebh,o_EX ;ex de,hl
2751 db 0ffh,0f9h,o_LD ;ld sp,hl
2753 db 0cfh,003h,o_INC ;inc rr
2755 db 0cfh,00bh,o_DEC ;dec rr
2757 db 0c7h,004h,o_INC ;inc r
2759 db 0c7h,005h,o_DEC ;dec r
2761 db 0ffh,008h,o_EX ;ex af,af'
2763 db 0cfh,009h,o_ADD ;add hl,rr
2765 db 0efh,002h,o_LD ;ld (rr),a ;rr=bc,de
2767 db 0efh,00ah,o_LD ;ld a,(rr) ;rr=bc,de
2773 db 0c7h,006h,o_LD ;ld r,nn
2775 db 0ffh,0c6h,o_ADD ;add a,nn
2777 db 0ffh,0ceh,o_ADC ;adc a,nn
2779 db 0ffh,0d6h,o_SUB ;sub nn
2781 db 0ffh,0deh,o_SBC ;sbc a,nn
2783 db 0ffh,0e6h,o_AND ;and nn
2785 db 0ffh,0eeh,o_XOR ;xor nn
2787 db 0ffh,0f6h,o_OR ;or nn
2789 db 0ffh,0feh,o_CP ;cp nn
2791 db 0ffh,010h,o_DJNZ ;djnz
2793 db 0ffh,018h,o_JR ;jr
2795 db 0e7h,020h,o_JR ;jr cc,
2797 db 0ffh,0d3h,o_OUT ;out (nn),a
2799 db 0ffh,0dbh,o_IN ;in a,(nn)
2805 db 0c7h,0c2h,o_JP ;jp cc,mn
2807 db 0c7h,0c4h,o_CALL ;call cc,mn
2809 db 0cfh,001h,o_LD ;ld ww,mn
2811 db 0ffh,0c3h,o_JP ;jp mn
2813 db 0ffh,0cdh,o_CALL ;call mn
2815 db 0ffh,022h,o_LD ;ld (mn),hl
2817 db 0ffh,02ah,o_LD ;ld hl,(mn)
2819 db 0ffh,032h,o_LD ;ld (mn),a
2821 db 0ffh,03ah,o_LD ;ld a,(mn)
2825 ; Prefix ED + 1 byte opcode, no arguments
2826 ; Format: opcode, t_MNEMONICS index
2829 db 045h,o_RETN ;retn
2830 db 04dh,o_RETI ;reti
2836 db 0a3h,o_OUTI ;outi
2840 db 0abh,o_OUTD ;outd
2841 db 0b0h,o_LDIR ;ldir
2842 db 0b1h,o_CPIR ;cpir
2843 db 0b2h,o_INIR ;inir
2844 db 0b3h,o_OTIR ;otir
2845 db 0b8h,o_LDDR ;lddr
2846 db 0b9h,o_CPDR ;cpdr
2847 db 0bah,o_INDR ;indr
2848 db 0bbh,o_OTDR ;otdr
2849 db 08bh,o_OTDM ;otdm
2850 db 09bh,o_OTDMR ;otdmr
2851 db 083h,o_OTIM ;otim
2852 db 093h,o_OTIMR ;otimr
2857 db 0ffh,070h,0ffh ;in (c) ;
2859 db 0c7h,040h,o_IN ;in r,(c) ;r=b,c,d,e,h,l,a
2861 db 0ffh,071h,0ffh ;out (c),0 ;
2863 db 0c7h,041h,o_OUT ;out (c),r ;r=b,c,d,e,h,l,a
2865 db 0cfh,042h,o_SBC ;sbc hl,rr
2867 db 0cfh,04ah,o_ADC ;adc hl,rr
2869 db 0ffh,046h,o_IM ;im 0
2871 db 0ffh,056h,o_IM ;im 1
2873 db 0ffh,05eh,o_IM ;im 2
2875 db 0e7h,047h,o_LD ;ld i,a ... ld a,r
2877 db 0cfh,04ch,o_MLT ;mlt rr
2879 db 0c7h,004h,o_TST ;tst r
2884 db 0ffh,030h,0ffh ;in0 (m)
2886 db 0c7h,000h,o_IN0 ;in0 r,(m) ;r=b,c,d,e,h,l,a
2888 db 0ffh,031h,0ffh ;out0 (m),0
2890 db 0c7h,001h,o_OUT0 ;out0 (m),r ;r=b,c,d,e
2892 db 0ffh,064h,o_TST ;tst m
2894 db 0ffh,074h,o_TSTIO ;tstio m
2898 ; Prefix ED + 1 byte opcode + 2 byte address
2899 ; Format: db mask, match, t_MNEMONICS-index
2900 ; dw argument formating function
2902 db 0cfh,043h,o_LD ;ld (mn),ww ;ww=bc,de,hl,sp
2904 db 0cfh,04bh,o_LD ;ld ww,(mn) ;ww=bc,de,hl,sp
2910 db 0f8h,000h,o_RLC ;rlc g
2912 db 0f8h,008h,o_RRC ;rrc g
2914 db 0f8h,010h,o_RL ;rl g
2916 db 0f8h,018h,o_RR ;rr g
2918 db 0f8h,020h,o_SLA ;sla g
2920 db 0f8h,028h,o_SRA ;sra g
2922 db 0f8h,038h,o_SRL ;srl g
2924 db 0c0h,040h,o_BIT ;bit b,g
2926 db 0c0h,080h,o_RES ;res b,g
2928 db 0c0h,0c0h,o_SET ;set b,g
2932 ;-------------------------------------------------------------------------------
3005 ld a,(isprefix_ixiy)
3055 ld (disas_argtype),a
3056 ld (disas_arg_16),hl
3158 ld a,(isprefix_ixiy)
3178 ld a,(isprefix_ixiy)
3202 ld a,(isprefix_ixiy)
3227 ld a,(isprefix_ixiy)
3273 ;-------------------------------------------------------------------------------
3278 o_&x equ $-opc_tabstart
3280 opc_index defl opc_index+1
3285 i_&x&y equ opc_index
3286 o_&x&y equ $-opc_tabstart
3288 i_&y equ opc_index+1
3289 o_&y equ $-opc_tabstart
3291 opc_index defl opc_index+2
3433 ;-------------------------------------------------------------------------------
3443 ld hl,l20edh ;set break after BDOS call
3446 call disas_get_instrlen
3461 call c,bp_trace_enter
3466 ;-------------------------------------------------------------------------------
3469 db 0ffh,0ddh,0 ;Prefix DD
3471 db 0ffh,0fdh,0 ;Prefix FD
3473 db 0ffh,0edh,0 ;Prefix ED
3476 db 0ffh,0cdh,0 ;call mn
3478 db 0ffh,0c3h,0 ;jp mn
3480 db 0ffh,0e9h,0 ;jp ()
3484 db 0ffh,0cfh,0 ;rst 8
3486 db 0c7h,0c7h,0 ;rst n
3488 db 0c7h,0c4h,0 ;call cc,mn
3490 db 0f7h,010h,0 ;djnz d; jr d
3492 db 0e7h,020h,0 ;jr cc,d
3494 db 0c7h,0c2h,0 ;jp cc,mn
3496 db 0c7h,0c0h,0 ;ret cc
3500 ;-------------------------------------------------------------------------------
3501 ; call mn call cc,mn
3539 cp 0e9h ; jp (ix); jp (iy)
3573 ld hl,(reg_sp) ;break on return address
3597 ;-------------------------------------------------------------------------------
3599 ; >>C[N][J] W expression
3600 ; >>C[N][J] U expression
3601 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3604 ;-------------------------------------------------------------------------------
3606 ; >>T[N][J] W expression
3607 ; >>T[N][J] U expression
3608 ; Trace [no List] [Jumps only] / .While. / .Until.
3612 ld hl,1 ;default: 1 step
3613 call get_lastarg_def
3614 ld (trace_cnt_or_ptr),hl
3616 ld (bp_p_cpu_flag),a
3621 call bp_clr_temporary
3622 ld hl,(trace_cnt_or_ptr)
3624 ld (trace_cnt_or_ptr),hl
3632 ld (bp_p_cpu_flag),a
3636 ;-------------------------------------------------------------------------------
3641 ;-------------------------------------------------------------------------------
3659 current_cseg defl $ - current_cseg
3660 .phase current_phase + current_cseg
3663 LD SP,ldr_end+(stack-ddtz_base)
3664 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
3677 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
3678 ld bc,0108h ;init bit counter
3682 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
3686 INC DE ;size rounded up to next page boundary
3689 SBC HL,DE ;BDOS - size
3690 LD (BDOS+1),HL ;-> new BDOS entry
3705 ld b,c ;reload bit counter
3706 LD e,(HL) ;get next 8 relocation bits
3732 LD HL,conbuf+2-ddtz_base
3736 current_phase defl $
3740 ds EXPR_BUF_SIZE - ($ - expr_buf)
3743 ;-------------------------------------------------------------------------------
3776 ddtz_size equ $-ddtz_base
3779 ;-------------------------------------------------------------------------------