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 ;-------------------------------------------------------------------------------
469 ;-------------------------------------------------------------------------------
507 ;-------------------------------------------------------------------------------
529 ;-------------------------------------------------------------------------------
555 ;-------------------------------------------------------------------------------
562 ld de,stack-(STACK_SIZE-28)
569 ;-------------------------------------------------------------------------------
595 ;-------------------------------------------------------------------------------
663 ;-------------------------------------------------------------------------------
843 jr z,error0 ;'S', but no expression following
847 ;-------------------------------------------------------------------------------
868 ;-------------------------------------------------------------------------------
913 ld hl,tab_func_eqlege
1015 ; de: x (x shifted out, q shifted in)
1017 ; hl: r (initially 0)
1099 ;-------------------------------------------------------------------------------
1147 jr z,fact_factstring
1154 ;-------------------------------------------------------------------------------
1257 ld hl,ddtz_base ;symtbl start
1277 pop hl ;inpsym ptr (discard)
1299 fs_cont: ;start over
1308 ;-------------------------------------------------------------------------------
1416 ;-------------------------------------------------------------------------------
1564 ;-------------------------------------------------------------------------------
1565 ; > G [startaddr] [;breakp..]
1566 ; Go [to start] [with temporary breakpoints]
1570 ld (trace_call_flag),a
1585 ;-------------------------------------------------------------------------------
1591 ld (pbl_loop_adr),hl
1602 ld hl,(pbl_loop_adr)
1612 call bp_clr_condition
1617 ;-------------------------------------------------------------------------------
1619 ; display all breakpoints
1620 ; > B breakp [breakp..]
1623 ; clear all breakpoints
1624 ; > BX address [address..]
1628 ; [R] expression [I condition]
1664 call bp_clr_condition
1709 ;-------------------------------------------------------------------------------
1710 ; Add break points to list
1711 ; A = 1 Permanent (B command)
1712 ; A = 2 Temporary (G command)
1733 call bp_get_freeslot
1740 call bp_get_condition
1805 ;-------------------------------------------------------------------------------
1847 call bp_clr_temporary
1950 call bp_get_freeslot
1993 ;-------------------------------------------------------------------------------
2028 ;-------------------------------------------------------------------------------
2082 ;-------------------------------------------------------------------------------
2084 ; examine all Y variables
2086 ; examine (and substitute) an Y variable
2114 call c,p_align_@_sym
2136 ;-------------------------------------------------------------------------------
2138 ; eXamine (display) all cpu registers and
2139 ; the instruction at the current program counter
2141 ; eXamine (and substitute) a register
2373 ;-------------------------------------------------------------------------------
2379 call get_lastarg_def
2413 ;-------------------------------------------------------------------------------
2415 ; examine (substitute) displacement register @
2427 ;-------------------------------------------------------------------------------
2429 ; Input a byte from port
2435 call get_lastarg_def
2447 ;-------------------------------------------------------------------------------
2449 ; Output a byte to a port
2461 call get_lastarg_def
2469 ;-------------------------------------------------------------------------------
2470 ; > Vstartaddr endaddr targetaddr
2471 ; Verify (compare) two memory areas
2504 ;-------------------------------------------------------------------------------
2505 ; > M[V] startaddr endaddr destaddr
2506 ; Move memory [and verify]
2528 db 01h ;swallow ldir instruction (ld bc,...)
2538 ;-------------------------------------------------------------------------------
2540 ; display Highest load address of last filed loaded, Maximum "High"
2541 ; off all loaded files, and Top address of available memory
2543 ; display symbol list
2545 ; evaluate expression and display result in hex, decimal and other formats
2546 ; > H expression expression
2547 ; display sum und difference of expressions
2633 ;-------------------------------------------------------------------------------
2634 ; > Q[J] startaddr endaddr bytes
2635 ; Query memory for a byte string [Justified]
2676 ;-------------------------------------------------------------------------------
2677 ; > Z startaddr endaddr bytes
2678 ; Zap (fill) memory with a byte string
2730 db 0e6h ; and 037h (clear carry)
2793 ;-------------------------------------------------------------------------------
2794 ; >>D [startaddr] [endaddr]
2795 ; Display memory in hex and ASCII
2865 ;-------------------------------------------------------------------------------
2867 ; specifiy filenames and command line
2998 ;-------------------------------------------------------------------------------
3016 ;-------------------------------------------------------------------------------
3141 ;-------------------------------------------------------------------------------
3142 ; > R [displacement]
3143 ; Read a binary or hex file and or symbol file [add displacement]
3147 call get_lastarg_def
3187 call read_byte ; RECORD MARK
3192 call read_hexchar ; RECLEN
3194 call read_hexchar ; LOAD ADDR H
3196 call read_hexchar ; LOAD ADDR L
3201 call read_hexchar ; RECTYP
3203 call read_hexchar ; DATA
3212 call read_hexchar ; CHKSUM
3229 db 'SYMBOLS',CR,LF+80h
3244 call read_hexbyte0 ; symval H
3246 call read_hexbyte ; symval L
3252 rs_3: call read_byte
3260 ld b,0 ; setup symlen
3263 call read_byte ; next char of symbol name
3264 call test_sym_char ; valid char?
3281 call test_symterm_ch
3324 ; test for valid character for symbols
3337 ret c ; cy == 1 --> z == 0
3342 ; check if char is in [0..9,?,@,A..Z,a..z]
3343 ; return cy if invalid
3344 ; return nc if valid alfanumeric char
3378 ;-------------------------------------------------------------------------------
3397 ;-------------------------------------------------------------------------------
3398 ; > Wstartaddr endaddr
3399 ; Write a file to disk
3433 ld de,080h ; DMA_BUF
3462 ;-------------------------------------------------------------------------------
3464 ; Assemble Zilog Z180 mnemonics
3468 call get_lastarg_def
3498 call nz,asemble_line
3535 ;-------------------------------------------------------------------------------
3542 dw as.AND_CP_OR_SUB_XOR ;AND
3548 dw as.opc.noarg ;CCF
3550 dw as.AND_CP_OR_SUB_XOR ;CP
3554 dw gen.opc.ED2 ;CPDR
3558 dw gen.opc.ED2 ;CPIR
3560 dw as.opc.noarg ;CPL
3562 dw as.opc.noarg ;DAA
3574 dw as.opc.noarg ;EXX
3576 dw as.opc.noarg ;HALT
3586 dw gen.opc.ED2 ;INDR
3590 dw gen.opc.ED2 ;INIR
3600 dw gen.opc.ED2 ;LDDR
3604 dw gen.opc.ED2 ;LDIR
3608 dw as.opc.noarg ;NOP
3610 dw as.AND_CP_OR_SUB_XOR ;OR
3612 dw gen.opc.ED2 ;OTDR
3614 dw gen.opc.ED2 ;OTIR
3618 dw gen.opc.ED2 ;OUTD
3620 dw gen.opc.ED2 ;OUTI
3624 dw as.POP_PUSH ;PUSH
3630 dw gen.opc.ED2 ;RETI
3632 dw gen.opc.ED2 ;RETN
3636 dw as.opc.noarg ;RLA
3640 dw as.opc.noarg ;RLCA
3646 dw as.opc.noarg ;RRA
3650 dw as.opc.noarg ;RRCA
3658 dw as.opc.noarg ;SCF
3668 dw as.AND_CP_OR_SUB_XOR ;SUB
3670 dw as.AND_CP_OR_SUB_XOR ;XOR
3677 dw gen.opc.ED2 ;OTDM
3679 dw gen.opc.ED2 ;OTDMR
3681 dw gen.opc.ED2 ;OTIM
3683 dw gen.opc.ED2 ;OTIMR
3694 ;-------------------------------------------------------------------------------
3722 call arg.addr_8bit ;
3726 call arg.addr_8bit ;
3759 call arg.IDX_displcmnt
3776 call test_paren_close
3843 call arg.IDX_displcmnt
3911 call test_paren_close
3919 call test_paren_close
3967 jr as.opc.noarg ;14ca
3975 call test_paren_close
4001 call test_paren_close
4033 call test_paren_close
4055 jr nc,as.AND_CP_OR_SUB_XOR
4077 jr nc,as.AND_CP_OR_SUB_XOR
4098 as.AND_CP_OR_SUB_XOR:
4113 call arg.IDX_displcmnt
4130 call arg.IDX_displcmnt
4160 call arg.IDX_displcmnt
4401 call arg.IDX_displcmnt
4629 ;-------------------------------------------------------------------------------
4630 ; >>L [startaddr] [endaddr]
4631 ; List disassembled code
4666 ;-------------------------------------------------------------------------------
4698 ;-------------------------------------------------------------------------------
4713 ;-------------------------------------------------------------------------------
4717 ld (disas_argtype),a
4718 call disas_get_instrlen
4729 ld a,(disas_argtype)
4730 ld hl,(disas_arg_16)
4744 ld (isprefix_ixiy),a
4763 ld (isprefix_ixiy),a
4774 ;-------------------------------------------------------------------------------
4802 ;-------------------------------------------------------------------------------
4803 ; DD/FD 3 byte (ix+d)/(iy+d)
4850 ;-------------------------------------------------------------------------------
4872 ;-------------------------------------------------------------------------------
4877 ld a,(isprefix_ixiy)
4888 ;-------------------------------------------------------------------------------
4909 ;-------------------------------------------------------------------------------
4966 ;-------------------------------------------------------------------------------
4967 ; 1 byte opcodes (no parameters)
4968 ; Format: db opcode, t_MNEMONICS-index
4987 ; Format: db mask, match, t_MNEMONICS-index
4988 ; dw argument formating fuction
4990 db 0c0h,040h,056h ;ld r,r
4992 db 0f8h,080h,003h ;add a,r
4994 db 0f8h,088h,000h ;adc a,r
4996 db 0f8h,090h,0c9h ;sub r
4998 db 0f8h,098h,0b7h ;sbc a,r
5000 db 0f8h,0a0h,006h ;and r
5002 db 0f8h,0a8h,0cch ;xor r
5004 db 0f8h,0b0h,06ch ;or r
5006 db 0f8h,0b8h,013h ;cp r
5008 db 0c7h,0c0h,08bh ;ret cc
5010 db 0c7h,0c7h,0b4h ;rst
5012 db 0ffh,0c9h,08bh ;ret
5014 db 0cfh,0c1h,081h ;pop rr
5016 db 0cfh,0c5h,084h ;push rr
5018 db 0ffh,0e3h,034h ;ex (sp),hl
5020 db 0ffh,0e9h,052h ;jp (hl)
5022 db 0ffh,0ebh,034h ;ex de,hl
5024 db 0ffh,0f9h,056h ;ld sp,hl
5026 db 0cfh,003h,041h ;inc rr
5028 db 0cfh,00bh,029h ;dec rr
5030 db 0c7h,004h,041h ;inc r
5032 db 0c7h,005h,029h ;dec r
5034 db 0ffh,008h,034h ;ex af,af'
5036 db 0cfh,009h,003h ;add hl,rr
5038 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
5040 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
5046 db 0c7h,006h,056h ;ld r,nn
5048 db 0ffh,0c6h,003h ;add a,nn
5050 db 0ffh,0ceh,000h ;adc a,nn
5052 db 0ffh,0d6h,0c9h ;sub a,nn
5054 db 0ffh,0deh,0b7h ;sbc a,nn
5056 db 0ffh,0e6h,006h ;and a,nn
5058 db 0ffh,0eeh,0cch ;xor nn
5060 db 0ffh,0f6h,06ch ;or nn
5062 db 0ffh,0feh,013h ;cp a,nn
5064 db 0ffh,010h,02eh ;djnz
5066 db 0ffh,018h,054h ;jr
5068 db 0e7h,020h,054h ;jr cc,
5070 db 0ffh,0d3h,076h ;out (nn),a
5072 db 0ffh,0dbh,03fh ;in a,(nn)
5078 db 0c7h,0c2h,052h ;jp cc,mn
5080 db 0c7h,0c4h,00ch ;call cc,mn
5082 db 0cfh,001h,056h ;ld ww,mn
5084 db 0ffh,0c3h,052h ;jp mn
5086 db 0ffh,0cdh,00ch ;call mn
5088 db 0ffh,022h,056h ;ld (mn),hl
5090 db 0ffh,02ah,056h ;ld hl,(mn)
5092 db 0ffh,032h,056h ;ld (mn),a
5094 db 0ffh,03ah,056h ;ld a,(mn)
5098 ; Prefix ED + 1 byte opcode, no arguments
5099 ; Format: opcode, t_MNEMONICS index
5130 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
5132 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
5134 db 0ffh,078h,03fh ;in r,(c) ;r=a
5136 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
5138 db 0f7h,061h,076h ;out (c),r ;r=h,l
5140 db 0ffh,079h,076h ;out (c),r ;r=a
5142 db 0cfh,042h,0b7h ;sbc hl,rr
5144 db 0cfh,04ah,000h ;adc hl,rr
5146 db 0ffh,046h,03dh ;im 0
5148 db 0ffh,056h,03dh ;im 1
5150 db 0ffh,05eh,03dh ;im 2
5152 db 0ffh,047h,056h ;ld i,a
5154 db 0ffh,057h,056h ;ld a,i
5156 db 0ffh,04fh,056h ;ld r,a
5158 db 0ffh,05fh,056h ;ld a,r
5160 db 0cfh,04ch,0d2h ;mlt rr
5162 db 0c7h,004h,0eeh ;tst r
5167 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
5169 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
5171 db 0ffh,038h,0cfh ;in0 a,(m)
5173 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
5175 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
5177 db 0ffh,039h,0e7h ;out0 (m),a
5179 db 0ffh,064h,0eeh ;tst m
5181 db 0ffh,074h,0f1h ;tstio m
5186 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
5188 db 0ffh,073h,056h ;ld (mn),sp
5190 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
5192 db 0ffh,07bh,056h ;ld sp,(mn)
5198 db 0f8h,000h,09bh ;rlc g
5200 db 0f8h,008h,0aah ;rrc g
5202 db 0f8h,010h,096h ;rl g
5204 db 0f8h,018h,0a5h ;rr g
5206 db 0f8h,020h,0c0h ;sla g
5208 db 0f8h,028h,0c3h ;sra g
5210 db 0f8h,038h,0c6h ;srl g
5212 db 0c0h,040h,009h ;bit b,g
5214 db 0c0h,080h,088h ;res b,g
5216 db 0c0h,0c0h,0bdh ;set b,g
5220 ;-------------------------------------------------------------------------------
5293 ld a,(isprefix_ixiy)
5339 ld (disas_argtype),a
5340 ld (disas_arg_16),hl
5436 ld a,(isprefix_ixiy)
5456 ld a,(isprefix_ixiy)
5489 ld a,(isprefix_ixiy)
5494 ld a,(isprefix_ixiy)
5526 ld a,(isprefix_ixiy)
5558 ;-------------------------------------------------------------------------------
5711 ;-------------------------------------------------------------------------------
5724 call disas_get_instrlen
5744 ;-------------------------------------------------------------------------------
5747 db 0ffh,0ddh,000h ;Prefix DD
5749 db 0ffh,0fdh,000h ;Prefix FD
5751 db 0ffh,0edh,000h ;Prefix ED
5755 db 0ffh,0cdh,000h ;call mn
5757 db 0ffh,0c3h,000h ;jp mn
5759 db 0ffh,0e9h,000h ;jp ()
5761 db 0ffh,0c9h,000h ;ret
5763 db 0ffh,0cfh,000h ;rst 8
5779 ;-------------------------------------------------------------------------------
5785 ld a,(trace_call_flag)
5850 ld a,(trace_call_flag)
5877 ld a,(trace_call_flag)
5887 ;-------------------------------------------------------------------------------
5889 ; >>C[N][J] W expression
5890 ; >>C[N][J] U expression
5891 ; trace over Calls [No list] [Jumps only] /.While./.Until.
5898 ;-------------------------------------------------------------------------------
5900 ; >>T[N][J] W expression
5901 ; >>T[N][J] U expression
5902 ; Trace [no List] [Jumps only] / .While. / .Until.
5909 ld (trace_call_flag),a
5925 call get_lastarg_def
5935 call bp_clr_temporary
5946 ld a,(trace_UW_flag)
5982 ld (trace_UW_flag),a
5997 ld (trace_UW_flag),a
6017 ;-------------------------------------------------------------------------------
6022 db 0 ;1=call, 0=trace
6024 db 0 ;0 or 'U' or 'W'
6032 ;-------------------------------------------------------------------------------
6053 current_cseg defl $ - current_cseg
6054 .phase current_phase + current_cseg
6057 LD SP,ldr_end+(stack-ddtz_base)
6058 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
6071 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
6072 ld bc,0108h ;init bit counter
6076 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
6080 INC DE ;size rounded up to next page boundary
6083 SBC HL,DE ;BDOS - size
6084 LD (BDOS+1),HL ;-> new BDOS entry
6099 ld b,c ;reload bit counter
6100 LD e,(HL) ;get next 8 relocation bits
6126 LD HL,conbuf+2-ddtz_base
6130 current_phase defl $
6134 ds EXPR_BUF_SIZE - ($ - expr_buf)
6137 ;-------------------------------------------------------------------------------
6193 symlen_cur: ;max length of symbols read so far
6200 ddtz_size equ $-ddtz_base
6203 ;-------------------------------------------------------------------------------