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_CIN equ 1 ;Console Input
47 BDOS_COUT equ 2 ;Console Output
48 BDOS_PSTR equ 9 ;Print String
49 BDOS_CBUF equ 10 ;Read Console Buffer
50 BDOS_CSTAT equ 11 ;Get Console Status
51 BDOS_OPEN equ 15 ;Open File
52 BDOS_CLOSE equ 16 ;Close File
53 BDOS_DELETE equ 19 ;Delete File
54 BDOS_READ equ 20 ;Read Sequential
55 BDOS_WRITE equ 21 ;Write Sequential
56 BDOS_CREATE equ 22 ;Make File
57 BDOS_SETDMA equ 26 ;Set DMA Address
59 ; ddtz specific definitions
61 STACK_SIZE equ 80 ;ddtz internal stack
62 CONBUF_SIZE equ 80 ;Size of console input buffer
63 EXPR_BUF_SIZE equ 128 ;expressen buffer for conditional breakpoints
64 BP_CNT equ 12 ;Number of breakpoints
65 BP_SIZE equ 8 ;Size of a breakpoint record
66 YREG_CNT equ 10 ;Number of Y registers (0..9)
68 SYMCASE_SENS equ 0 ;Symbols are case sensitive
69 SYMCASE_CONV equ 1 ;Convert case when symbols are loaded
70 SYMCASE_LOWER equ 2 ;Convert to lower case if set, else to upper case
72 ;-------------------------------------------------------------------------------
92 current_cseg defl $ - current_cseg
93 .phase current_phase + current_cseg
95 db 'Symbolic DDTZ/180'
101 db 'Z80 or better required!',cr,lf,'$'
106 ds STACK_SIZE - (current_phase - signon)
138 error_func:dw p_msg_error
141 ;-------------------------------------------------------------------------------
184 ds CONBUF_SIZE + 3 - ($ - conbuf)
186 ;-------------------------------------------------------------------------------
189 dw cmd_@ ;examine/substitute the displacement register @
191 dw cmd_B ;Breakpoints display/set/clear
192 dw cmd_C ;trace over Calls
193 dw cmd_D ;Display memory in hex and ascii
195 dw cmd_F ;specify Filename and command line
197 dw cmd_H ;compute Hex and other expressions
198 dw cmd_I ;Input a byte from port
201 dw cmd_L ;List disassembled code
202 dw cmd_M ;Move memory [and verify]
204 dw cmd_O ;Output a byte to port
206 dw cmd_Q ;Qery memory for byte string
207 dw cmd_R ;Read binary or hex file and/or symbol file
208 dw cmd_S ;Substitute memory
211 dw cmd_V ;Verify (compare) two memory areas
212 dw cmd_W ;Write a file to disk
213 dw cmd_X ;eXamine [and substitute] registers
214 dw cmd_Y ;examine [and substitute] Y variables
215 dw cmd_Z ;Zap (fill) memory with a byte string
223 call bp_clr_temporary
256 ;-------------------------------------------------------------------------------
299 defb 03eh ;ld a,.. swallow push hl
463 ;-------------------------------------------------------------------------------
501 ;-------------------------------------------------------------------------------
523 ;-------------------------------------------------------------------------------
549 ;-------------------------------------------------------------------------------
556 ld de,stack-(STACK_SIZE-28)
563 ;-------------------------------------------------------------------------------
589 ;-------------------------------------------------------------------------------
657 ;-------------------------------------------------------------------------------
783 defb 0e6h ;and a,.. clear carry
795 defb 03eh ;ld a,.. swallow pop af
837 jr z,error0 ;'S', but no expression following
841 ;-------------------------------------------------------------------------------
862 ;-------------------------------------------------------------------------------
907 ld hl,tab_func_eqlege
1009 ; de: x (x shifted out, q shifted in)
1011 ; hl: r (initially 0)
1093 ;-------------------------------------------------------------------------------
1141 jr z,fact_factstring
1148 ;-------------------------------------------------------------------------------
1251 ld hl,ddtz_base ;symtbl start
1271 pop hl ;inpsym ptr (discard)
1293 fs_cont: ;start over
1302 ;-------------------------------------------------------------------------------
1410 ;-------------------------------------------------------------------------------
1458 ld hl,t_flag_names+7
1559 ;-------------------------------------------------------------------------------
1560 ; > G [startaddr] [;breakp..]
1561 ; Go [to start] [with temporary breakpoints]
1565 ld (trace_call_flag),a
1580 ;-------------------------------------------------------------------------------
1586 ld (pbl_loop_adr),hl
1597 ld hl,(pbl_loop_adr)
1607 call bp_clr_condition
1612 ;-------------------------------------------------------------------------------
1614 ; display all breakpoints
1615 ; > B breakp [breakp..]
1618 ; clear all breakpoints
1619 ; > BX address [address..]
1623 ; [R] expression [I condition]
1659 call bp_clr_condition
1704 ;-------------------------------------------------------------------------------
1705 ; Add break points to list
1706 ; A = 1 Permanent (B command)
1707 ; A = 2 Temporary (G command)
1728 call bp_get_freeslot
1735 call bp_get_condition
1800 ;-------------------------------------------------------------------------------
1842 call bp_clr_temporary
1945 call bp_get_freeslot
1988 ;-------------------------------------------------------------------------------
2023 ;-------------------------------------------------------------------------------
2077 ;-------------------------------------------------------------------------------
2079 ; examine all Y variables
2081 ; examine (and substitute) an Y variable
2109 call c,p_align_@_sym
2131 ;-------------------------------------------------------------------------------
2133 ; eXamine (display) all cpu registers and
2134 ; the instruction at the current program counter
2136 ; eXamine (and substitute) a register
2366 ;-------------------------------------------------------------------------------
2372 call get_lastarg_def
2406 ;-------------------------------------------------------------------------------
2408 ; examine (substitute) displacement register @
2420 ;-------------------------------------------------------------------------------
2422 ; Input a byte from port
2428 call get_lastarg_def
2440 ;-------------------------------------------------------------------------------
2442 ; Output a byte to a port
2454 call get_lastarg_def
2462 ;-------------------------------------------------------------------------------
2463 ; > Vstartaddr endaddr targetaddr
2464 ; Verify (compare) two memory areas
2497 ;-------------------------------------------------------------------------------
2498 ; > M[V] startaddr endaddr destaddr
2499 ; Move memory [and verify]
2521 db 01h ;swallow ldir instruction (ld bc,...)
2531 ;-------------------------------------------------------------------------------
2533 ; display Highest load address of last filed loaded, Maximum "High"
2534 ; off all loaded files, and Top address of available memory
2536 ; display symbol list
2538 ; evaluate expression and display result in hex, decimal and other formats
2539 ; > H expression expression
2540 ; display sum und difference of expressions
2626 ;-------------------------------------------------------------------------------
2627 ; > Q[J] startaddr endaddr bytes
2628 ; Query memory for a byte string [Justified]
2669 ;-------------------------------------------------------------------------------
2670 ; > Z startaddr endaddr bytes
2671 ; Zap (fill) memory with a byte string
2723 db 0e6h ; and 037h (clear carry)
2786 ;-------------------------------------------------------------------------------
2787 ; >>D [startaddr] [endaddr]
2788 ; Display memory in hex and ASCII
2858 ;-------------------------------------------------------------------------------
2860 ; specifiy filenames and command line
2991 ;-------------------------------------------------------------------------------
3009 ;-------------------------------------------------------------------------------
3134 ;-------------------------------------------------------------------------------
3135 ; > R [displacement]
3136 ; Read a binary or hex file and or symbol file [add displacement]
3140 call get_lastarg_def
3180 call read_byte ; RECORD MARK
3185 call read_hexchar ; RECLEN
3187 call read_hexchar ; LOAD ADDR H
3189 call read_hexchar ; LOAD ADDR L
3194 call read_hexchar ; RECTYP
3196 call read_hexchar ; DATA
3205 call read_hexchar ; CHKSUM
3222 db 'SYMBOLS',CR,LF+80h
3237 call read_hexbyte0 ; symval H
3239 call read_hexbyte ; symval L
3245 rs_3: call read_byte
3253 ld b,0 ; setup symlen
3256 call read_byte ; next char of symbol name
3257 call test_sym_char ; valid char?
3274 call test_symterm_ch
3317 ; test for valid character for symbols
3330 ret c ; cy == 1 --> z == 0
3335 ; check if char is in [0..9,?,@,A..Z,a..z]
3336 ; return cy if invalid
3337 ; return nc if valid alfanumeric char
3371 ;-------------------------------------------------------------------------------
3390 ;-------------------------------------------------------------------------------
3391 ; > Wstartaddr endaddr
3392 ; Write a file to disk
3426 ld de,080h ; DMA_BUF
3455 ;-------------------------------------------------------------------------------
3457 ; Assemble Zilog Z180 mnemonics
3461 call get_lastarg_def
3491 call nz,asemble_line
3528 ;-------------------------------------------------------------------------------
3535 dw as.AND_CP_OR_SUB_XOR ;AND
3541 dw as.opc.noarg ;CCF
3543 dw as.AND_CP_OR_SUB_XOR ;CP
3547 dw gen.opc.ED2 ;CPDR
3551 dw gen.opc.ED2 ;CPIR
3553 dw as.opc.noarg ;CPL
3555 dw as.opc.noarg ;DAA
3567 dw as.opc.noarg ;EXX
3569 dw as.opc.noarg ;HALT
3579 dw gen.opc.ED2 ;INDR
3583 dw gen.opc.ED2 ;INIR
3593 dw gen.opc.ED2 ;LDDR
3597 dw gen.opc.ED2 ;LDIR
3601 dw as.opc.noarg ;NOP
3603 dw as.AND_CP_OR_SUB_XOR ;OR
3605 dw gen.opc.ED2 ;OTDR
3607 dw gen.opc.ED2 ;OTIR
3611 dw gen.opc.ED2 ;OUTD
3613 dw gen.opc.ED2 ;OUTI
3617 dw as.POP_PUSH ;PUSH
3623 dw gen.opc.ED2 ;RETI
3625 dw gen.opc.ED2 ;RETN
3629 dw as.opc.noarg ;RLA
3633 dw as.opc.noarg ;RLCA
3639 dw as.opc.noarg ;RRA
3643 dw as.opc.noarg ;RRCA
3651 dw as.opc.noarg ;SCF
3661 dw as.AND_CP_OR_SUB_XOR ;SUB
3663 dw as.AND_CP_OR_SUB_XOR ;XOR
3670 dw gen.opc.ED2 ;OTDM
3672 dw gen.opc.ED2 ;OTDMR
3674 dw gen.opc.ED2 ;OTIM
3676 dw gen.opc.ED2 ;OTIMR
3687 ;-------------------------------------------------------------------------------
3715 call arg.addr_8bit ;
3719 call arg.addr_8bit ;
3752 call arg.IDX_displcmnt
3769 call test_paren_close
3836 call arg.IDX_displcmnt
3904 call test_paren_close
3912 call test_paren_close
3960 jr as.opc.noarg ;14ca
3968 call test_paren_close
3994 call test_paren_close
4026 call test_paren_close
4048 jr nc,as.AND_CP_OR_SUB_XOR
4070 jr nc,as.AND_CP_OR_SUB_XOR
4091 as.AND_CP_OR_SUB_XOR:
4106 call arg.IDX_displcmnt
4123 call arg.IDX_displcmnt
4153 call arg.IDX_displcmnt
4394 call arg.IDX_displcmnt
4622 ;-------------------------------------------------------------------------------
4623 ; >>L [startaddr] [endaddr]
4624 ; List disassembled code
4659 ;-------------------------------------------------------------------------------
4691 ;-------------------------------------------------------------------------------
4706 ;-------------------------------------------------------------------------------
4710 ld (disas_argtype),a
4711 call disas_get_instrlen
4722 ld a,(disas_argtype)
4723 ld hl,(disas_arg_16)
4737 ld (isprefix_ixiy),a
4756 ld (isprefix_ixiy),a
4767 ;-------------------------------------------------------------------------------
4795 ;-------------------------------------------------------------------------------
4796 ; DD/FD 3 byte (ix+d)/(iy+d)
4843 ;-------------------------------------------------------------------------------
4865 ;-------------------------------------------------------------------------------
4870 ld a,(isprefix_ixiy)
4881 ;-------------------------------------------------------------------------------
4902 ;-------------------------------------------------------------------------------
4959 ;-------------------------------------------------------------------------------
4960 ; 1 byte opcodes (no parameters)
4961 ; Format: db opcode, t_MNEMONICS-index
4980 ; Format: db mask, match, t_MNEMONICS-index
4981 ; dw argument formating fuction
4983 db 0c0h,040h,056h ;ld r,r
4985 db 0f8h,080h,003h ;add a,r
4987 db 0f8h,088h,000h ;adc a,r
4989 db 0f8h,090h,0c9h ;sub r
4991 db 0f8h,098h,0b7h ;sbc a,r
4993 db 0f8h,0a0h,006h ;and r
4995 db 0f8h,0a8h,0cch ;xor r
4997 db 0f8h,0b0h,06ch ;or r
4999 db 0f8h,0b8h,013h ;cp r
5001 db 0c7h,0c0h,08bh ;ret cc
5003 db 0c7h,0c7h,0b4h ;rst
5005 db 0ffh,0c9h,08bh ;ret
5007 db 0cfh,0c1h,081h ;pop rr
5009 db 0cfh,0c5h,084h ;push rr
5011 db 0ffh,0e3h,034h ;ex (sp),hl
5013 db 0ffh,0e9h,052h ;jp (hl)
5015 db 0ffh,0ebh,034h ;ex de,hl
5017 db 0ffh,0f9h,056h ;ld sp,hl
5019 db 0cfh,003h,041h ;inc rr
5021 db 0cfh,00bh,029h ;dec rr
5023 db 0c7h,004h,041h ;inc r
5025 db 0c7h,005h,029h ;dec r
5027 db 0ffh,008h,034h ;ex af,af'
5029 db 0cfh,009h,003h ;add hl,rr
5031 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
5033 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
5039 db 0c7h,006h,056h ;ld r,nn
5041 db 0ffh,0c6h,003h ;add a,nn
5043 db 0ffh,0ceh,000h ;adc a,nn
5045 db 0ffh,0d6h,0c9h ;sub a,nn
5047 db 0ffh,0deh,0b7h ;sbc a,nn
5049 db 0ffh,0e6h,006h ;and a,nn
5051 db 0ffh,0eeh,0cch ;xor nn
5053 db 0ffh,0f6h,06ch ;or nn
5055 db 0ffh,0feh,013h ;cp a,nn
5057 db 0ffh,010h,02eh ;djnz
5059 db 0ffh,018h,054h ;jr
5061 db 0e7h,020h,054h ;jr cc,
5063 db 0ffh,0d3h,076h ;out (nn),a
5065 db 0ffh,0dbh,03fh ;in a,(nn)
5071 db 0c7h,0c2h,052h ;jp cc,mn
5073 db 0c7h,0c4h,00ch ;call cc,mn
5075 db 0cfh,001h,056h ;ld ww,mn
5077 db 0ffh,0c3h,052h ;jp mn
5079 db 0ffh,0cdh,00ch ;call mn
5081 db 0ffh,022h,056h ;ld (mn),hl
5083 db 0ffh,02ah,056h ;ld hl,(mn)
5085 db 0ffh,032h,056h ;ld (mn),a
5087 db 0ffh,03ah,056h ;ld a,(mn)
5091 ; Prefix ED + 1 byte opcode, no arguments
5092 ; Format: opcode, t_MNEMONICS index
5123 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
5125 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
5127 db 0ffh,078h,03fh ;in r,(c) ;r=a
5129 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
5131 db 0f7h,061h,076h ;out (c),r ;r=h,l
5133 db 0ffh,079h,076h ;out (c),r ;r=a
5135 db 0cfh,042h,0b7h ;sbc hl,rr
5137 db 0cfh,04ah,000h ;adc hl,rr
5139 db 0ffh,046h,03dh ;im 0
5141 db 0ffh,056h,03dh ;im 1
5143 db 0ffh,05eh,03dh ;im 2
5145 db 0ffh,047h,056h ;ld i,a
5147 db 0ffh,057h,056h ;ld a,i
5149 db 0ffh,04fh,056h ;ld r,a
5151 db 0ffh,05fh,056h ;ld a,r
5153 db 0cfh,04ch,0d2h ;mlt rr
5155 db 0c7h,004h,0eeh ;tst r
5160 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
5162 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
5164 db 0ffh,038h,0cfh ;in0 a,(m)
5166 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
5168 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
5170 db 0ffh,039h,0e7h ;out0 (m),a
5172 db 0ffh,064h,0eeh ;tst m
5174 db 0ffh,074h,0f1h ;tstio m
5179 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
5181 db 0ffh,073h,056h ;ld (mn),sp
5183 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
5185 db 0ffh,07bh,056h ;ld sp,(mn)
5191 db 0f8h,000h,09bh ;rlc g
5193 db 0f8h,008h,0aah ;rrc g
5195 db 0f8h,010h,096h ;rl g
5197 db 0f8h,018h,0a5h ;rr g
5199 db 0f8h,020h,0c0h ;sla g
5201 db 0f8h,028h,0c3h ;sra g
5203 db 0f8h,038h,0c6h ;srl g
5205 db 0c0h,040h,009h ;bit b,g
5207 db 0c0h,080h,088h ;res b,g
5209 db 0c0h,0c0h,0bdh ;set b,g
5213 ;-------------------------------------------------------------------------------
5285 ld a,(isprefix_ixiy)
5335 ld (disas_argtype),a
5336 ld (disas_arg_16),hl
5444 ld a,(isprefix_ixiy)
5464 ld a,(isprefix_ixiy)
5486 ld a,(isprefix_ixiy)
5491 ld a,(isprefix_ixiy)
5521 ld a,(isprefix_ixiy)
5553 ;-------------------------------------------------------------------------------
5706 ;-------------------------------------------------------------------------------
5719 call disas_get_instrlen
5739 ;-------------------------------------------------------------------------------
5742 db 0ffh,0ddh,000h ;Prefix DD
5744 db 0ffh,0fdh,000h ;Prefix FD
5746 db 0ffh,0edh,000h ;Prefix ED
5750 db 0ffh,0cdh,000h ;call mn
5752 db 0ffh,0c3h,000h ;jp mn
5754 db 0ffh,0e9h,000h ;jp ()
5756 db 0ffh,0c9h,000h ;ret
5758 db 0ffh,0cfh,000h ;rst 8
5774 ;-------------------------------------------------------------------------------
5780 ld a,(trace_call_flag)
5845 ld a,(trace_call_flag)
5872 ld a,(trace_call_flag)
5882 ;-------------------------------------------------------------------------------
5884 ; >>C[N][J] W expression
5885 ; >>C[N][J] U expression
5886 ; trace over Calls [No list] [Jumps only] /.While./.Until.
5893 ;-------------------------------------------------------------------------------
5895 ; >>T[N][J] W expression
5896 ; >>T[N][J] U expression
5897 ; Trace [no List] [Jumps only] / .While. / .Until.
5904 ld (trace_call_flag),a
5920 call get_lastarg_def
5930 call bp_clr_temporary
5941 ld a,(trace_UW_flag)
5977 ld (trace_UW_flag),a
5992 ld (trace_UW_flag),a
6012 ;-------------------------------------------------------------------------------
6017 db 0 ;1=call, 0=trace
6019 db 0 ;0 or 'U' or 'W'
6027 ;-------------------------------------------------------------------------------
6048 current_cseg defl $ - current_cseg
6049 .phase current_phase + current_cseg
6052 LD SP,ldr_end+(stack-ddtz_base)
6053 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
6066 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
6067 ld bc,0108h ;init bit counter
6071 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
6075 INC DE ;size rounded up to next page boundary
6078 SBC HL,DE ;BDOS - size
6079 LD (BDOS+1),HL ;-> new BDOS entry
6094 ld b,c ;reload bit counter
6095 LD e,(HL) ;get next 8 relocation bits
6121 LD HL,conbuf+2-ddtz_base
6125 current_phase defl $
6129 ds EXPR_BUF_SIZE - ($ - expr_buf)
6132 ;-------------------------------------------------------------------------------
6188 symlen_cur: ;max length of symbols read so far
6195 ddtz_size equ $-ddtz_base
6198 ;-------------------------------------------------------------------------------