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 6 ;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 ;-------------------------------------------------------------------------------
796 ;-------------------------------------------------------------------------------
841 ld hl,tab_func_eqlege
943 ; de: x (x shifted out, q shifted in)
945 ; hl: r (initially 0)
1020 ;-------------------------------------------------------------------------------
1063 jr z,fact_factstring
1068 ;-------------------------------------------------------------------------------
1154 ;-------------------------------------------------------------------------------
1262 ;-------------------------------------------------------------------------------
1309 ld hl,t_flag_names+7
1404 ;-------------------------------------------------------------------------------
1405 ; > G [startaddr] [;breakp..]
1406 ; Go [to start] [with temporary breakpoints]
1410 ld (bp_p_cpu_flag),a
1425 ;-------------------------------------------------------------------------------
1431 ld (pbl_loop_adr),hl
1444 ld hl,(pbl_loop_adr)
1458 ;-------------------------------------------------------------------------------
1460 ; display all breakpoints
1461 ; > B breakp [breakp..]
1464 ; clear all breakpoints
1465 ; > BX address [address..]
1529 ;-------------------------------------------------------------------------------
1530 ; Add break points to list
1531 ; A = 1 Permanent (B command)
1532 ; A = 2 Temporary (G command)
1549 call bp_get_freeslot
1583 ;-------------------------------------------------------------------------------
1584 ; Breakpoint handling routine.
1618 call inchar ;Keyboard hit?
1626 call bp_clr_temporary
1639 ld (bp_p_cpu_flag),a
1714 call bp_get_freeslot
1755 ;-------------------------------------------------------------------------------
1760 ld a,(bp_p_cpu_flag)
1790 ;-------------------------------------------------------------------------------
1792 ; examine all Y variables
1794 ; examine (and substitute) an Y variable
1797 ;-------------------------------------------------------------------------------
1799 ; eXamine (display) all cpu registers and
1800 ; the instruction at the current program counter
1802 ; eXamine (and substitute) a register
2029 ;-------------------------------------------------------------------------------
2035 call get_lastarg_def
2069 ;-------------------------------------------------------------------------------
2071 ; examine (substitute) displacement register @
2075 ;-------------------------------------------------------------------------------
2077 ; Input a byte from port
2082 call get_lastarg_def
2094 ;-------------------------------------------------------------------------------
2096 ; Output a byte to a port
2107 call get_lastarg_def
2115 ;-------------------------------------------------------------------------------
2116 ; > Vstartaddr endaddr targetaddr
2117 ; Verify (compare) two memory areas
2150 ;-------------------------------------------------------------------------------
2151 ; > M[V] startaddr endaddr destaddr
2152 ; Move memory [and verify]
2174 db 01h ;swallow ldir instruction (ld bc,...)
2184 ;-------------------------------------------------------------------------------
2186 ; display Highest load address of last filed loaded, Maximum "High"
2187 ; off all loaded files, and Top address of available memory
2189 ; evaluate expression and display result in hex, decimal and other formats
2209 ;-------------------------------------------------------------------------------
2210 ; > Q[J] startaddr endaddr bytes
2211 ; Query memory for a byte string [Justified]
2252 ;-------------------------------------------------------------------------------
2253 ; > Z startaddr endaddr bytes
2254 ; Zap (fill) memory with a byte string
2306 db 0e6h ; and 037h (clear carry)
2369 ;-------------------------------------------------------------------------------
2370 ; >>D [startaddr] [endaddr]
2371 ; Display memory in hex and ASCII
2440 ;-------------------------------------------------------------------------------
2442 ; specifiy filenames and command line
2446 ;-------------------------------------------------------------------------------
2447 ; > R [displacement]
2448 ; Read Intel Hex File from console [add displacement]
2452 call get_lastarg_def ;get offset from command line
2461 ld c,0 ;init checksum
2462 call i.gethexbyte ;record len
2464 call i.gethexbyte ;address high
2466 call i.gethexbyte ;address low
2468 call i.gethexbyte ;record type (ignored)
2470 and a ;record len == 0?
2481 djnz l16c6h ;repeat for record len
2482 call i.gethexbyte ;checksum
2485 jp nz,ERROR ;exit if checksum error
2486 jr w_recstart ;next record
2523 ld de,TPA ;lowest allowed load address
2526 ld de,(BDOS+1) ;highest allowed load address
2541 ld (hl),a ;store byte
2544 ;-------------------------------------------------------------------------------
2563 ;-------------------------------------------------------------------------------
2564 ; > Wstartaddr endaddr
2565 ; Write a file to disk
2569 ;-------------------------------------------------------------------------------
2571 ; Assemble Zilog Z180 mnemonics
2579 ;-------------------------------------------------------------------------------
2593 ;-------------------------------------------------------------------------------
2594 ; >>L [startaddr] [endaddr]
2595 ; List disassembled code
2629 ;-------------------------------------------------------------------------------
2657 ;-------------------------------------------------------------------------------
2660 ;-------------------------------------------------------------------------------
2664 ld (disas_argtype),a
2665 call disas_get_instrlen
2676 ld a,(disas_argtype)
2677 ld hl,(disas_arg_16)
2691 ld (isprefix_ixiy),a
2710 ld (isprefix_ixiy),a
2721 ;-------------------------------------------------------------------------------
2749 ;-------------------------------------------------------------------------------
2750 ; DD/FD 3 byte (ix+d)/(iy+d)
2797 ;-------------------------------------------------------------------------------
2819 ;-------------------------------------------------------------------------------
2824 ld a,(isprefix_ixiy)
2835 ;-------------------------------------------------------------------------------
2856 ;-------------------------------------------------------------------------------
2913 ;-------------------------------------------------------------------------------
2914 ; 1 byte opcodes (no parameters)
2915 ; Format: db opcode, t_MNEMONICS-index
2934 ; Format: db mask, match, t_MNEMONICS-index
2935 ; dw argument formating fuction
2937 db 0c0h,040h,056h ;ld r,r
2939 db 0f8h,080h,003h ;add a,r
2941 db 0f8h,088h,000h ;adc a,r
2943 db 0f8h,090h,0c9h ;sub r
2945 db 0f8h,098h,0b7h ;sbc a,r
2947 db 0f8h,0a0h,006h ;and r
2949 db 0f8h,0a8h,0cch ;xor r
2951 db 0f8h,0b0h,06ch ;or r
2953 db 0f8h,0b8h,013h ;cp r
2955 db 0c7h,0c0h,08bh ;ret cc
2957 db 0c7h,0c7h,0b4h ;rst
2959 db 0ffh,0c9h,08bh ;ret
2961 db 0cfh,0c1h,081h ;pop rr
2963 db 0cfh,0c5h,084h ;push rr
2965 db 0ffh,0e3h,034h ;ex (sp),hl
2967 db 0ffh,0e9h,052h ;jp (hl)
2969 db 0ffh,0ebh,034h ;ex de,hl
2971 db 0ffh,0f9h,056h ;ld sp,hl
2973 db 0cfh,003h,041h ;inc rr
2975 db 0cfh,00bh,029h ;dec rr
2977 db 0c7h,004h,041h ;inc r
2979 db 0c7h,005h,029h ;dec r
2981 db 0ffh,008h,034h ;ex af,af'
2983 db 0cfh,009h,003h ;add hl,rr
2985 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
2987 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
2993 db 0c7h,006h,056h ;ld r,nn
2995 db 0ffh,0c6h,003h ;add a,nn
2997 db 0ffh,0ceh,000h ;adc a,nn
2999 db 0ffh,0d6h,0c9h ;sub a,nn
3001 db 0ffh,0deh,0b7h ;sbc a,nn
3003 db 0ffh,0e6h,006h ;and a,nn
3005 db 0ffh,0eeh,0cch ;xor nn
3007 db 0ffh,0f6h,06ch ;or nn
3009 db 0ffh,0feh,013h ;cp a,nn
3011 db 0ffh,010h,02eh ;djnz
3013 db 0ffh,018h,054h ;jr
3015 db 0e7h,020h,054h ;jr cc,
3017 db 0ffh,0d3h,076h ;out (nn),a
3019 db 0ffh,0dbh,03fh ;in a,(nn)
3025 db 0c7h,0c2h,052h ;jp cc,mn
3027 db 0c7h,0c4h,00ch ;call cc,mn
3029 db 0cfh,001h,056h ;ld ww,mn
3031 db 0ffh,0c3h,052h ;jp mn
3033 db 0ffh,0cdh,00ch ;call mn
3035 db 0ffh,022h,056h ;ld (mn),hl
3037 db 0ffh,02ah,056h ;ld hl,(mn)
3039 db 0ffh,032h,056h ;ld (mn),a
3041 db 0ffh,03ah,056h ;ld a,(mn)
3045 ; Prefix ED + 1 byte opcode, no arguments
3046 ; Format: opcode, t_MNEMONICS index
3077 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
3079 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
3081 db 0ffh,078h,03fh ;in r,(c) ;r=a
3083 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
3085 db 0f7h,061h,076h ;out (c),r ;r=h,l
3087 db 0ffh,079h,076h ;out (c),r ;r=a
3089 db 0cfh,042h,0b7h ;sbc hl,rr
3091 db 0cfh,04ah,000h ;adc hl,rr
3093 db 0ffh,046h,03dh ;im 0
3095 db 0ffh,056h,03dh ;im 1
3097 db 0ffh,05eh,03dh ;im 2
3099 db 0ffh,047h,056h ;ld i,a
3101 db 0ffh,057h,056h ;ld a,i
3103 db 0ffh,04fh,056h ;ld r,a
3105 db 0ffh,05fh,056h ;ld a,r
3107 db 0cfh,04ch,0d2h ;mlt rr
3109 db 0c7h,004h,0eeh ;tst r
3114 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
3116 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
3118 db 0ffh,038h,0cfh ;in0 a,(m)
3120 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
3122 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
3124 db 0ffh,039h,0e7h ;out0 (m),a
3126 db 0ffh,064h,0eeh ;tst m
3128 db 0ffh,074h,0f1h ;tstio m
3133 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
3135 db 0ffh,073h,056h ;ld (mn),sp
3137 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
3139 db 0ffh,07bh,056h ;ld sp,(mn)
3145 db 0f8h,000h,09bh ;rlc g
3147 db 0f8h,008h,0aah ;rrc g
3149 db 0f8h,010h,096h ;rl g
3151 db 0f8h,018h,0a5h ;rr g
3153 db 0f8h,020h,0c0h ;sla g
3155 db 0f8h,028h,0c3h ;sra g
3157 db 0f8h,038h,0c6h ;srl g
3159 db 0c0h,040h,009h ;bit b,g
3161 db 0c0h,080h,088h ;res b,g
3163 db 0c0h,0c0h,0bdh ;set b,g
3167 ;-------------------------------------------------------------------------------
3239 ld a,(isprefix_ixiy)
3289 ld (disas_argtype),a
3290 ld (disas_arg_16),hl
3399 ld a,(isprefix_ixiy)
3419 ld a,(isprefix_ixiy)
3441 ld a,(isprefix_ixiy)
3446 ld a,(isprefix_ixiy)
3476 ld a,(isprefix_ixiy)
3508 ;-------------------------------------------------------------------------------
3639 ;-------------------------------------------------------------------------------
3652 call disas_get_instrlen
3667 call c,bp_trace_enter
3672 ;-------------------------------------------------------------------------------
3675 db 0ffh,0ddh,000h ;Prefix DD
3677 db 0ffh,0fdh,000h ;Prefix FD
3679 db 0ffh,0edh,000h ;Prefix ED
3683 db 0ffh,0cdh,000h ;call mn
3685 db 0ffh,0c3h,000h ;jp mn
3687 db 0ffh,0e9h,000h ;jp ()
3689 db 0ffh,0c9h,000h ;ret
3691 db 0ffh,0cfh,000h ;rst 8
3693 db 0c7h,0c7h,000h ;rst n
3695 db 0c7h,0c4h,000h ;call cc,mn
3697 db 0f7h,010h,000h ;djnz d; jr d
3699 db 0e7h,020h,000h ;jr cc,d
3701 db 0c7h,0c2h,000h ;jp cc,mn
3703 db 0c7h,0c0h,000h ;ret cc
3707 ;-------------------------------------------------------------------------------
3708 ; call mn call cc,mn
3746 cp 0e9h ; jp (ix); jp (iy)
3805 ;-------------------------------------------------------------------------------
3807 ; >>C[N][J] W expression
3808 ; >>C[N][J] U expression
3809 ; trace over Calls [No list] [Jumps only] /.While./.Until.
3812 ;-------------------------------------------------------------------------------
3814 ; >>T[N][J] W expression
3815 ; >>T[N][J] U expression
3816 ; Trace [no List] [Jumps only] / .While. / .Until.
3820 ld hl,1 ;default: 1 step
3821 call get_lastarg_def
3822 ld (trace_cnt_or_ptr),hl
3824 ld (bp_p_cpu_flag),a
3829 call bp_clr_temporary
3830 ld hl,(trace_cnt_or_ptr)
3832 ld (trace_cnt_or_ptr),hl
3840 ld (bp_p_cpu_flag),a
3844 ;-------------------------------------------------------------------------------
3849 ;-------------------------------------------------------------------------------
3867 current_cseg defl $ - current_cseg
3868 .phase current_phase + current_cseg
3871 LD SP,ldr_end+(stack-ddtz_base)
3872 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
3885 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
3886 ld bc,0108h ;init bit counter
3890 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
3894 INC DE ;size rounded up to next page boundary
3897 SBC HL,DE ;BDOS - size
3898 LD (BDOS+1),HL ;-> new BDOS entry
3913 ld b,c ;reload bit counter
3914 LD e,(HL) ;get next 8 relocation bits
3940 LD HL,conbuf+2-ddtz_base
3944 current_phase defl $
3948 ds EXPR_BUF_SIZE - ($ - expr_buf)
3951 ;-------------------------------------------------------------------------------
3987 ddtz_size equ $-ddtz_base
3990 ;-------------------------------------------------------------------------------