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
2701 db 076h,o_HALT ;halt
2706 db 007h,o_RLCA ;rlca
2707 db 00fh,o_RRCA ;rrca
2719 ; Format: db mask, match, t_MNEMONICS-index
2720 ; dw argument formating fuction
2722 db 0c0h,040h,o_LD ;ld r,r
2724 db 0f8h,080h,o_ADD ;add a,r
2726 db 0f8h,088h,o_ADC ;adc a,r
2728 db 0f8h,090h,o_SUB ;sub r
2730 db 0f8h,098h,o_SBC ;sbc a,r
2732 db 0f8h,0a0h,o_AND ;and r
2734 db 0f8h,0a8h,o_XOR ;xor r
2736 db 0f8h,0b0h,o_OR ;or r
2738 db 0f8h,0b8h,o_CP ;cp r
2740 db 0c7h,0c0h,o_RET ;ret cc
2742 db 0c7h,0c7h,o_RST ;rst
2744 db 0cfh,0c1h,o_POP ;pop rr
2746 db 0cfh,0c5h,o_PUSH ;push rr
2748 db 0ffh,0e3h,o_EX ;ex (sp),hl
2750 db 0ffh,0e9h,o_JP ;jp (hl)
2752 db 0ffh,0ebh,o_EX ;ex de,hl
2754 db 0ffh,0f9h,o_LD ;ld sp,hl
2756 db 0cfh,003h,o_INC ;inc rr
2758 db 0cfh,00bh,o_DEC ;dec rr
2760 db 0c7h,004h,o_INC ;inc r
2762 db 0c7h,005h,o_DEC ;dec r
2764 db 0ffh,008h,o_EX ;ex af,af'
2766 db 0cfh,009h,003h ;add hl,rr
2768 db 0efh,002h,o_LD ;ld (rr),a ;rr=bc,de
2770 db 0efh,00ah,o_LD ;ld a,(rr) ;rr=bc,de
2776 db 0c7h,006h,o_LD ;ld r,nn
2778 db 0ffh,0c6h,o_ADD ;add a,nn
2780 db 0ffh,0ceh,o_ADC ;adc a,nn
2782 db 0ffh,0d6h,o_SUB ;sub nn
2784 db 0ffh,0deh,o_SBC ;sbc a,nn
2786 db 0ffh,0e6h,o_AND ;and nn
2788 db 0ffh,0eeh,o_XOR ;xor nn
2790 db 0ffh,0f6h,o_OR ;or nn
2792 db 0ffh,0feh,o_CP ;cp nn
2794 db 0ffh,010h,o_DJNZ ;djnz
2796 db 0ffh,018h,o_JR ;jr
2798 db 0e7h,020h,o_JR ;jr cc,
2800 db 0ffh,0d3h,o_OUT ;out (nn),a
2802 db 0ffh,0dbh,o_IN ;in a,(nn)
2808 db 0c7h,0c2h,o_JP ;jp cc,mn
2810 db 0c7h,0c4h,o_CALL ;call cc,mn
2812 db 0cfh,001h,o_LD ;ld ww,mn
2814 db 0ffh,0c3h,o_JP ;jp mn
2816 db 0ffh,0cdh,o_CALL ;call mn
2818 db 0ffh,022h,o_LD ;ld (mn),hl
2820 db 0ffh,02ah,o_LD ;ld hl,(mn)
2822 db 0ffh,032h,o_LD ;ld (mn),a
2824 db 0ffh,03ah,o_LD ;ld a,(mn)
2828 ; Prefix ED + 1 byte opcode, no arguments
2829 ; Format: opcode, t_MNEMONICS index
2832 db 045h,o_RETN ;retn
2833 db 04dh,o_RETI ;reti
2839 db 0a3h,o_OUTI ;outi
2843 db 0abh,o_OUTD ;outd
2844 db 0b0h,o_LDIR ;ldir
2845 db 0b1h,o_CPIR ;cpir
2846 db 0b2h,o_INIR ;inir
2847 db 0b3h,o_OTIR ;otir
2848 db 0b8h,o_LDDR ;lddr
2849 db 0b9h,o_CPDR ;cpdr
2850 db 0bah,o_INDR ;indr
2851 db 0bbh,o_OTDR ;otdr
2852 db 08bh,o_OTDM ;otdm
2853 db 09bh,o_OTDMR ;otdmr
2854 db 083h,o_OTDM ;otim
2855 db 093h,o_OTDMR ;otimr
2860 db 0e7h,040h,o_IN ;in r,(c) ;r=b,c,d,e
2862 db 0f7h,060h,o_IN ;in r,(c) ;r=h,l
2864 db 0ffh,078h,o_IN ;in r,(c) ;r=a
2866 db 0e7h,041h,o_OUT ;out (c),r ;r=b,c,d,e
2868 db 0f7h,061h,o_OUT ;out (c),r ;r=h,l
2870 db 0ffh,079h,o_OUT ;out (c),r ;r=a
2872 db 0cfh,042h,o_SBC ;sbc hl,rr
2874 db 0cfh,04ah,o_ADC ;adc hl,rr
2876 db 0ffh,046h,o_IM ;im 0
2878 db 0ffh,056h,o_IM ;im 1
2880 db 0ffh,05eh,o_IM ;im 2
2882 db 0e7h,047h,o_LD ;ld i,a ... ld a,r
2884 db 0cfh,04ch,o_MLT ;mlt rr
2886 db 0c7h,004h,o_TST ;tst r
2891 db 0e7h,000h,o_IN ;in0 r,(m) ;r=b,c,d,e
2893 db 0f7h,020h,o_IN ;in0 r,(m) ;r=h,l
2895 db 0ffh,038h,o_IN ;in0 a,(m)
2897 db 0e7h,001h,o_OUT0 ;out0 (m),r ;r=b,c,d,e
2899 db 0f7h,021h,o_OUT0 ;out0 (m),r ;r=h,l
2901 db 0ffh,039h,o_OUT0 ;out0 (m),a
2903 db 0ffh,064h,o_TST ;tst m
2905 db 0ffh,074h,o_TSTIO ;tstio m
2910 db 0efh,043h,o_LD ;ld (mn),ww ;ww=bc,de
2912 db 0ffh,073h,o_LD ;ld (mn),sp
2914 db 0efh,04bh,o_LD ;ld ww,(mn) ;ww=bc,de
2916 db 0ffh,07bh,o_LD ;ld sp,(mn)
2922 db 0f8h,000h,o_RLC ;rlc g
2924 db 0f8h,008h,o_RRC ;rrc g
2926 db 0f8h,010h,o_RL ;rl g
2928 db 0f8h,018h,o_RR ;rr g
2930 db 0f8h,020h,o_SLA ;sla g
2932 db 0f8h,028h,o_SRA ;sra g
2934 db 0f8h,038h,o_SRL ;srl g
2936 db 0c0h,040h,o_BIT ;bit b,g
2938 db 0c0h,080h,o_RES ;res b,g
2940 db 0c0h,0c0h,o_SET ;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 ;-------------------------------------------------------------------------------
3282 opc_index defl opc_index+1
3283 opc_offset defl opc_offset+$-pos
3408 ;-------------------------------------------------------------------------------
3418 ld hl,l20edh ;set break after BDOS call
3421 call disas_get_instrlen
3436 call c,bp_trace_enter
3441 ;-------------------------------------------------------------------------------
3444 db 0ffh,0ddh,0 ;Prefix DD
3446 db 0ffh,0fdh,0 ;Prefix FD
3448 db 0ffh,0edh,0 ;Prefix ED
3451 db 0ffh,0cdh,0 ;call mn
3453 db 0ffh,0c3h,0 ;jp mn
3455 db 0ffh,0e9h,0 ;jp ()
3459 db 0ffh,0cfh,0 ;rst 8
3461 db 0c7h,0c7h,0 ;rst n
3463 db 0c7h,0c4h,0 ;call cc,mn
3465 db 0f7h,010h,0 ;djnz d; jr d
3467 db 0e7h,020h,0 ;jr cc,d
3469 db 0c7h,0c2h,0 ;jp cc,mn
3471 db 0c7h,0c0h,0 ;ret cc
3475 ;-------------------------------------------------------------------------------
3476 ; call mn call cc,mn
3514 cp 0e9h ; jp (ix); jp (iy)
3548 ld hl,(reg_sp) ;break on return address
3572 ;-------------------------------------------------------------------------------
3574 ; >>C[N][J] W expression
3575 ; >>C[N][J] U expression
3576 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3579 ;-------------------------------------------------------------------------------
3581 ; >>T[N][J] W expression
3582 ; >>T[N][J] U expression
3583 ; Trace [no List] [Jumps only] / .While. / .Until.
3587 ld hl,1 ;default: 1 step
3588 call get_lastarg_def
3589 ld (trace_cnt_or_ptr),hl
3591 ld (bp_p_cpu_flag),a
3596 call bp_clr_temporary
3597 ld hl,(trace_cnt_or_ptr)
3599 ld (trace_cnt_or_ptr),hl
3607 ld (bp_p_cpu_flag),a
3611 ;-------------------------------------------------------------------------------
3616 ;-------------------------------------------------------------------------------
3634 current_cseg defl $ - current_cseg
3635 .phase current_phase + current_cseg
3638 LD SP,ldr_end+(stack-ddtz_base)
3639 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
3652 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
3653 ld bc,0108h ;init bit counter
3657 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
3661 INC DE ;size rounded up to next page boundary
3664 SBC HL,DE ;BDOS - size
3665 LD (BDOS+1),HL ;-> new BDOS entry
3680 ld b,c ;reload bit counter
3681 LD e,(HL) ;get next 8 relocation bits
3707 LD HL,conbuf+2-ddtz_base
3711 current_phase defl $
3715 ds EXPR_BUF_SIZE - ($ - expr_buf)
3718 ;-------------------------------------------------------------------------------
3751 ddtz_size equ $-ddtz_base
3754 ;-------------------------------------------------------------------------------