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
244 ;-------------------------------------------------------------------------------
264 defb 03eh ;ld a,.. swallow push hl
421 ;-------------------------------------------------------------------------------
428 ;-------------------------------------------------------------------------------
447 ;-------------------------------------------------------------------------------
472 ;-------------------------------------------------------------------------------
487 jr z,inl_e ;Accept line
489 jr z,inl_e ;Accept line
496 call DELC ;Delete Char
501 call DELL ;Delete Line
511 ld a,'^' ;Controll characters
532 ;-------------------------------------------------------------------------------
545 ;-------------------------------------------------------------------------------
556 ;-------------------------------------------------------------------------------
572 ;-------------------------------------------------------------------------------
579 ld de,stack-(STACK_SIZE-28)
586 ;-------------------------------------------------------------------------------
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)
930 ;-------------------------------------------------------------------------------
972 ;-------------------------------------------------------------------------------
1058 ;-------------------------------------------------------------------------------
1166 ;-------------------------------------------------------------------------------
1210 ld hl,t_flag_names+7
1305 ;-------------------------------------------------------------------------------
1306 ; > G [startaddr] [;breakp..]
1307 ; Go [to start] [with temporary breakpoints]
1311 ld (bp_p_cpu_flag),a
1326 ;-------------------------------------------------------------------------------
1332 ld (pbl_loop_adr),hl
1345 ld hl,(pbl_loop_adr)
1359 ;-------------------------------------------------------------------------------
1361 ; display all breakpoints
1362 ; > B breakp [breakp..]
1365 ; clear all breakpoints
1366 ; > BX breakp [breakp..]
1369 ; breakp can be any valid expression
1429 ;-------------------------------------------------------------------------------
1430 ; Add break points to list
1431 ; A = 1 Permanent (B command)
1432 ; A = 2 Temporary (G command)
1449 call bp_get_freeslot
1471 ;-------------------------------------------------------------------------------
1472 ; Breakpoint handling routine.
1506 call inchar ;Keyboard hit?
1514 call bp_clr_temporary
1527 ld (bp_p_cpu_flag),a
1584 call bp_get_freeslot
1623 ;-------------------------------------------------------------------------------
1628 ld a,(bp_p_cpu_flag)
1658 ;-------------------------------------------------------------------------------
1660 ; examine all Y variables
1662 ; examine (and substitute) an Y variable
1665 ;-------------------------------------------------------------------------------
1667 ; eXamine (display) all cpu registers and
1668 ; the instruction at the current program counter
1670 ; eXamine (and substitute) a register
1879 ;-------------------------------------------------------------------------------
1885 call get_lastarg_def
1919 ;-------------------------------------------------------------------------------
1921 ; examine (substitute) displacement register @
1925 ;-------------------------------------------------------------------------------
1927 ; Input a byte from port
1932 call get_lastarg_def
1944 ;-------------------------------------------------------------------------------
1946 ; Output a byte to a port
1957 call get_lastarg_def
1965 ;-------------------------------------------------------------------------------
1966 ; > Vstartaddr endaddr targetaddr
1967 ; Verify (compare) two memory areas
1997 ;-------------------------------------------------------------------------------
1998 ; > M startaddr endaddr destaddr
2012 db 01h ;swallow ldir instruction (ld bc,...)
2017 ;-------------------------------------------------------------------------------
2019 ; display Highest load address of last filed loaded, Maximum "High"
2020 ; off all loaded files, and Top address of available memory
2022 ; evaluate expression and display result in hex, decimal and other formats
2042 ;-------------------------------------------------------------------------------
2043 ; > Q[J] startaddr endaddr bytes
2044 ; Query memory for a byte string [Justified]
2084 ;-------------------------------------------------------------------------------
2085 ; > Z startaddr endaddr bytes
2086 ; Zap (fill) memory with a byte string
2120 sub_0ef7h: ;from cmd_Q, cmd_Z
2121 db 0e6h ;and 037h (clear carry)
2122 sub_0ef8h: ;from cmd_S
2170 ;-------------------------------------------------------------------------------
2171 ; >>D [startaddr] [endaddr]
2172 ; Display memory in hex and ASCII
2240 ;-------------------------------------------------------------------------------
2242 ; specifiy filenames and command line
2246 ;-------------------------------------------------------------------------------
2247 ; > R [displacement]
2248 ; Read Intel Hex File from console [add displacement]
2252 call get_lastarg_def ;get offset from command line
2261 ld c,0 ;init checksum
2262 call i.gethexbyte ;record len
2264 call i.gethexbyte ;address high
2266 call i.gethexbyte ;address low
2268 call i.gethexbyte ;record type (ignored)
2270 and a ;record len == 0?
2281 djnz l16c6h ;repeat for record len
2282 call i.gethexbyte ;checksum
2285 jr nz,error2 ;exit if checksum error
2286 jr w_recstart ;next record
2324 ld de,TPA ;lowest allowed load address
2327 ld de,(BDOS+1) ;highest allowed load address
2342 ld (hl),a ;store byte
2345 ;-------------------------------------------------------------------------------
2364 ;-------------------------------------------------------------------------------
2365 ; > Wstartaddr endaddr
2366 ; Write a file to disk
2370 ;-------------------------------------------------------------------------------
2372 ; Assemble Zilog Z180 mnemonics
2376 ;-------------------------------------------------------------------------------
2377 ; >>L [startaddr] [endaddr]
2378 ; List disassembled code
2412 ;-------------------------------------------------------------------------------
2431 ;-------------------------------------------------------------------------------
2434 call disas_get_instrlen
2440 call pstr ;print mnemonic
2443 call CALL_HL ;print arguments
2457 ld (isprefix_ixiy),a
2476 ld (isprefix_ixiy),a
2487 ;-------------------------------------------------------------------------------
2515 ;-------------------------------------------------------------------------------
2516 ; DD/FD 3 byte (ix+d)/(iy+d)
2563 ;-------------------------------------------------------------------------------
2585 ;-------------------------------------------------------------------------------
2590 ld a,(isprefix_ixiy)
2601 ;-------------------------------------------------------------------------------
2621 ;-------------------------------------------------------------------------------
2681 ;-------------------------------------------------------------------------------
2682 ; 1 byte opcodes (no parameters)
2683 ; Format: db opcode, t_MNEMONICS-index
2685 db 076h,o_HALT ;halt
2690 db 007h,o_RLCA ;rlca
2691 db 00fh,o_RRCA ;rrca
2703 ; Format: db mask, match, t_MNEMONICS-index
2704 ; dw argument formating function
2706 db 0c0h,040h,o_LD ;ld r[y],r[z]
2708 db 0f8h,080h,o_ADD ;add a,r[z]
2710 db 0f8h,088h,o_ADC ;adc a,r[z]
2712 db 0f8h,090h,o_SUB ;sub r[z]
2714 db 0f8h,098h,o_SBC ;sbc a,r[z]
2716 db 0f8h,0a0h,o_AND ;and r[z]
2718 db 0f8h,0a8h,o_XOR ;xor r[z]
2720 db 0f8h,0b0h,o_OR ;or r[z]
2722 db 0f8h,0b8h,o_CP ;cp r[z]
2724 db 0c7h,0c0h,o_RET ;ret cc
2726 db 0c7h,0c7h,o_RST ;rst
2728 db 0cfh,0c1h,o_POP ;pop rr
2730 db 0cfh,0c5h,o_PUSH ;push rr
2732 db 0ffh,0e3h,o_EX ;ex (sp),hl
2734 db 0ffh,0e9h,o_JP ;jp (hl)
2736 db 0ffh,0ebh,o_EX ;ex de,hl
2738 db 0ffh,0f9h,o_LD ;ld sp,hl
2740 db 0cfh,003h,o_INC ;inc rr
2742 db 0cfh,00bh,o_DEC ;dec rr
2744 db 0c7h,004h,o_INC ;inc r
2746 db 0c7h,005h,o_DEC ;dec r
2748 db 0ffh,008h,o_EX ;ex af,af'
2750 db 0cfh,009h,o_ADD ;add hl,rr
2752 db 0efh,002h,o_LD ;ld (rr),a ;rr=bc,de
2754 db 0efh,00ah,o_LD ;ld a,(rr) ;rr=bc,de
2760 db 0c7h,006h,o_LD ;ld r,nn
2762 db 0ffh,0c6h,o_ADD ;add a,nn
2764 db 0ffh,0ceh,o_ADC ;adc a,nn
2766 db 0ffh,0d6h,o_SUB ;sub nn
2768 db 0ffh,0deh,o_SBC ;sbc a,nn
2770 db 0ffh,0e6h,o_AND ;and nn
2772 db 0ffh,0eeh,o_XOR ;xor nn
2774 db 0ffh,0f6h,o_OR ;or nn
2776 db 0ffh,0feh,o_CP ;cp nn
2778 db 0ffh,010h,o_DJNZ ;djnz
2780 db 0ffh,018h,o_JR ;jr
2782 db 0e7h,020h,o_JR ;jr cc,
2784 db 0ffh,0d3h,o_OUT ;out (nn),a
2786 db 0ffh,0dbh,o_IN ;in a,(nn)
2792 db 0c7h,0c2h,o_JP ;jp cc,mn
2794 db 0c7h,0c4h,o_CALL ;call cc,mn
2796 db 0cfh,001h,o_LD ;ld ww,mn
2798 db 0ffh,0c3h,o_JP ;jp mn
2800 db 0ffh,0cdh,o_CALL ;call mn
2802 db 0ffh,022h,o_LD ;ld (mn),hl
2804 db 0ffh,02ah,o_LD ;ld hl,(mn)
2806 db 0ffh,032h,o_LD ;ld (mn),a
2808 db 0ffh,03ah,o_LD ;ld a,(mn)
2812 ; Prefix ED + 1 byte opcode, no arguments
2813 ; Format: opcode, t_MNEMONICS index
2816 db 045h,o_RETN ;retn
2817 db 04dh,o_RETI ;reti
2823 db 0a3h,o_OUTI ;outi
2827 db 0abh,o_OUTD ;outd
2828 db 0b0h,o_LDIR ;ldir
2829 db 0b1h,o_CPIR ;cpir
2830 db 0b2h,o_INIR ;inir
2831 db 0b3h,o_OTIR ;otir
2832 db 0b8h,o_LDDR ;lddr
2833 db 0b9h,o_CPDR ;cpdr
2834 db 0bah,o_INDR ;indr
2835 db 0bbh,o_OTDR ;otdr
2836 db 08bh,o_OTDM ;otdm
2837 db 09bh,o_OTDMR ;otdmr
2838 db 083h,o_OTIM ;otim
2839 db 093h,o_OTIMR ;otimr
2844 db 0ffh,070h,0ffh ;in (c) ;
2846 db 0c7h,040h,o_IN ;in r,(c) ;r=b,c,d,e,h,l,a
2848 db 0ffh,071h,0ffh ;out (c),0 ;
2850 db 0c7h,041h,o_OUT ;out (c),r ;r=b,c,d,e,h,l,a
2852 db 0cfh,042h,o_SBC ;sbc hl,rr
2854 db 0cfh,04ah,o_ADC ;adc hl,rr
2856 db 0ffh,046h,o_IM ;im 0
2858 db 0ffh,056h,o_IM ;im 1
2860 db 0ffh,05eh,o_IM ;im 2
2862 db 0e7h,047h,o_LD ;ld i,a ... ld a,r
2864 db 0cfh,04ch,o_MLT ;mlt rr
2866 db 0c7h,004h,o_TST ;tst r
2871 db 0ffh,030h,0ffh ;in0 (m)
2873 db 0c7h,000h,o_IN0 ;in0 r,(m) ;r=b,c,d,e,h,l,a
2875 db 0ffh,031h,0ffh ;out0 (m),0
2877 db 0c7h,001h,o_OUT0 ;out0 (m),r ;r=b,c,d,e
2879 db 0ffh,064h,o_TST ;tst m
2881 db 0ffh,074h,o_TSTIO ;tstio m
2885 ; Prefix ED + 1 byte opcode + 2 byte address
2886 ; Format: db mask, match, t_MNEMONICS-index
2887 ; dw argument formating function
2889 db 0cfh,043h,o_LD ;ld (mn),ww ;ww=bc,de,hl,sp
2891 db 0cfh,04bh,o_LD ;ld ww,(mn) ;ww=bc,de,hl,sp
2897 db 0f8h,000h,o_RLC ;rlc g
2899 db 0f8h,008h,o_RRC ;rrc g
2901 db 0f8h,010h,o_RL ;rl g
2903 db 0f8h,018h,o_RR ;rr g
2905 db 0f8h,020h,o_SLA ;sla g
2907 db 0f8h,028h,o_SRA ;sra g
2909 db 0f8h,038h,o_SRL ;srl g
2911 db 0c0h,040h,o_BIT ;bit b,g
2913 db 0c0h,080h,o_RES ;res b,g
2915 db 0c0h,0c0h,o_SET ;set b,g
2919 ;-------------------------------------------------------------------------------
2992 ld a,(isprefix_ixiy)
3139 ld a,(isprefix_ixiy)
3159 ld a,(isprefix_ixiy)
3183 ld a,(isprefix_ixiy)
3208 ld a,(isprefix_ixiy)
3254 ;-------------------------------------------------------------------------------
3259 o_&x equ $-opc_tabstart
3261 opc_index defl opc_index+1
3266 i_&x&y equ opc_index
3267 o_&x&y equ $-opc_tabstart
3269 i_&y equ opc_index+1
3270 o_&y equ $-opc_tabstart
3272 opc_index defl opc_index+2
3414 ;-------------------------------------------------------------------------------
3415 ;-------------------------------------------------------------------------------
3430 ld a,(hl) ;get next token
3435 call outchar ;print as normal character
3452 ; | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
3458 db fi_ry,',',fi_rz,0 ;ld r[y],r[z]
3459 db 'A,',fi_rz,0 ;op A,r[z]
3460 db fi_ry,',(',fi_m8,')',0 ;in a,(m8)
3461 db '(',fi_m8,'),',fi_ry,0 ;out (m8),a
3463 db '(SP),',fi_hlixiy,0 ;
3469 ;-------------------------------------------------------------------------------
3474 fi_&x equ 80h+argpf_index
3476 argpf_index defl argpf_index+1
3492 ;-------------------------------------------------------------------------------
3565 ld a,(isprefix_ixiy)
3615 ld (disas_argtype),a
3616 ld (disas_arg_16),hl
3718 ld a,(isprefix_ixiy)
3738 ld a,(isprefix_ixiy)
3762 ld a,(isprefix_ixiy)
3787 ld a,(isprefix_ixiy)
3821 ;-------------------------------------------------------------------------------
3822 ;-------------------------------------------------------------------------------
3832 ld hl,l20edh ;set break after BDOS call
3835 call disas_get_instrlen
3850 call c,bp_trace_enter
3855 ;-------------------------------------------------------------------------------
3858 db 0ffh,0ddh,0 ;Prefix DD
3860 db 0ffh,0fdh,0 ;Prefix FD
3862 db 0ffh,0edh,0 ;Prefix ED
3865 db 0ffh,0cdh,0 ;call mn
3867 db 0ffh,0c3h,0 ;jp mn
3869 db 0ffh,0e9h,0 ;jp ()
3873 db 0ffh,0cfh,0 ;rst 8
3875 db 0c7h,0c7h,0 ;rst n
3877 db 0c7h,0c4h,0 ;call cc,mn
3879 db 0f7h,010h,0 ;djnz d; jr d
3881 db 0e7h,020h,0 ;jr cc,d
3883 db 0c7h,0c2h,0 ;jp cc,mn
3885 db 0c7h,0c0h,0 ;ret cc
3889 ;-------------------------------------------------------------------------------
3890 ; call mn call cc,mn
3928 cp 0e9h ; jp (ix); jp (iy)
3962 ld hl,(reg_sp) ;break on return address
3986 ;-------------------------------------------------------------------------------
3988 ; >>C[N][J] W expression
3989 ; >>C[N][J] U expression
3990 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3993 ;-------------------------------------------------------------------------------
3995 ; >>T[N][J] W expression
3996 ; >>T[N][J] U expression
3997 ; Trace [no List] [Jumps only] / .While. / .Until.
4001 ld hl,1 ;default: 1 step
4002 call get_lastarg_def
4003 ld (trace_cnt_or_ptr),hl
4005 ld (bp_p_cpu_flag),a
4010 call bp_clr_temporary
4011 ld hl,(trace_cnt_or_ptr)
4013 ld (trace_cnt_or_ptr),hl
4021 ld (bp_p_cpu_flag),a
4025 ;-------------------------------------------------------------------------------
4030 ;-------------------------------------------------------------------------------
4048 current_cseg defl $ - current_cseg
4049 .phase current_phase + current_cseg
4052 LD SP,ldr_end+(stack-ddtz_base)
4053 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
4066 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
4067 ld bc,0108h ;init bit counter
4071 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
4075 INC DE ;size rounded up to next page boundary
4078 SBC HL,DE ;BDOS - size
4079 LD (BDOS+1),HL ;-> new BDOS entry
4094 ld b,c ;reload bit counter
4095 LD e,(HL) ;get next 8 relocation bits
4121 LD HL,conbuf+2-ddtz_base
4125 current_phase defl $
4129 ds EXPR_BUF_SIZE - ($ - expr_buf)
4132 ;-------------------------------------------------------------------------------
4161 ddtz_size equ $-ddtz_base
4164 ;-------------------------------------------------------------------------------