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
467 ;-------------------------------------------------------------------------------
505 ;-------------------------------------------------------------------------------
527 ;-------------------------------------------------------------------------------
553 ;-------------------------------------------------------------------------------
560 ld de,stack-(STACK_SIZE-28)
567 ;-------------------------------------------------------------------------------
593 ;-------------------------------------------------------------------------------
661 ;-------------------------------------------------------------------------------
787 defb 0e6h ;and a,.. clear carry
799 defb 03eh ;ld a,.. swallow pop af
841 jr z,error0 ;'S', but no expression following
845 ;-------------------------------------------------------------------------------
866 ;-------------------------------------------------------------------------------
911 ld hl,tab_func_eqlege
1013 ; de: x (x shifted out, q shifted in)
1015 ; hl: r (initially 0)
1097 ;-------------------------------------------------------------------------------
1145 jr z,fact_factstring
1152 ;-------------------------------------------------------------------------------
1255 ld hl,ddtz_base ;symtbl start
1275 pop hl ;inpsym ptr (discard)
1297 fs_cont: ;start over
1306 ;-------------------------------------------------------------------------------
1414 ;-------------------------------------------------------------------------------
1562 ;-------------------------------------------------------------------------------
1563 ; > G [startaddr] [;breakp..]
1564 ; Go [to start] [with temporary breakpoints]
1568 ld (trace_call_flag),a
1583 ;-------------------------------------------------------------------------------
1589 ld (pbl_loop_adr),hl
1600 ld hl,(pbl_loop_adr)
1610 call bp_clr_condition
1615 ;-------------------------------------------------------------------------------
1617 ; display all breakpoints
1618 ; > B breakp [breakp..]
1621 ; clear all breakpoints
1622 ; > BX address [address..]
1626 ; [R] expression [I condition]
1662 call bp_clr_condition
1707 ;-------------------------------------------------------------------------------
1708 ; Add break points to list
1709 ; A = 1 Permanent (B command)
1710 ; A = 2 Temporary (G command)
1731 call bp_get_freeslot
1738 call bp_get_condition
1803 ;-------------------------------------------------------------------------------
1845 call bp_clr_temporary
1948 call bp_get_freeslot
1991 ;-------------------------------------------------------------------------------
2026 ;-------------------------------------------------------------------------------
2080 ;-------------------------------------------------------------------------------
2082 ; examine all Y variables
2084 ; examine (and substitute) an Y variable
2112 call c,p_align_@_sym
2134 ;-------------------------------------------------------------------------------
2136 ; eXamine (display) all cpu registers and
2137 ; the instruction at the current program counter
2139 ; eXamine (and substitute) a register
2369 ;-------------------------------------------------------------------------------
2375 call get_lastarg_def
2409 ;-------------------------------------------------------------------------------
2411 ; examine (substitute) displacement register @
2423 ;-------------------------------------------------------------------------------
2425 ; Input a byte from port
2431 call get_lastarg_def
2443 ;-------------------------------------------------------------------------------
2445 ; Output a byte to a port
2457 call get_lastarg_def
2465 ;-------------------------------------------------------------------------------
2466 ; > Vstartaddr endaddr targetaddr
2467 ; Verify (compare) two memory areas
2500 ;-------------------------------------------------------------------------------
2501 ; > M[V] startaddr endaddr destaddr
2502 ; Move memory [and verify]
2524 db 01h ;swallow ldir instruction (ld bc,...)
2534 ;-------------------------------------------------------------------------------
2536 ; display Highest load address of last filed loaded, Maximum "High"
2537 ; off all loaded files, and Top address of available memory
2539 ; display symbol list
2541 ; evaluate expression and display result in hex, decimal and other formats
2542 ; > H expression expression
2543 ; display sum und difference of expressions
2629 ;-------------------------------------------------------------------------------
2630 ; > Q[J] startaddr endaddr bytes
2631 ; Query memory for a byte string [Justified]
2672 ;-------------------------------------------------------------------------------
2673 ; > Z startaddr endaddr bytes
2674 ; Zap (fill) memory with a byte string
2726 db 0e6h ; and 037h (clear carry)
2789 ;-------------------------------------------------------------------------------
2790 ; >>D [startaddr] [endaddr]
2791 ; Display memory in hex and ASCII
2861 ;-------------------------------------------------------------------------------
2863 ; specifiy filenames and command line
2994 ;-------------------------------------------------------------------------------
3012 ;-------------------------------------------------------------------------------
3137 ;-------------------------------------------------------------------------------
3138 ; > R [displacement]
3139 ; Read a binary or hex file and or symbol file [add displacement]
3143 call get_lastarg_def
3183 call read_byte ; RECORD MARK
3188 call read_hexchar ; RECLEN
3190 call read_hexchar ; LOAD ADDR H
3192 call read_hexchar ; LOAD ADDR L
3197 call read_hexchar ; RECTYP
3199 call read_hexchar ; DATA
3208 call read_hexchar ; CHKSUM
3225 db 'SYMBOLS',CR,LF+80h
3240 call read_hexbyte0 ; symval H
3242 call read_hexbyte ; symval L
3248 rs_3: call read_byte
3256 ld b,0 ; setup symlen
3259 call read_byte ; next char of symbol name
3260 call test_sym_char ; valid char?
3277 call test_symterm_ch
3320 ; test for valid character for symbols
3333 ret c ; cy == 1 --> z == 0
3338 ; check if char is in [0..9,?,@,A..Z,a..z]
3339 ; return cy if invalid
3340 ; return nc if valid alfanumeric char
3374 ;-------------------------------------------------------------------------------
3393 ;-------------------------------------------------------------------------------
3394 ; > Wstartaddr endaddr
3395 ; Write a file to disk
3429 ld de,080h ; DMA_BUF
3458 ;-------------------------------------------------------------------------------
3460 ; Assemble Zilog Z180 mnemonics
3464 call get_lastarg_def
3494 call nz,asemble_line
3531 ;-------------------------------------------------------------------------------
3538 dw as.AND_CP_OR_SUB_XOR ;AND
3544 dw as.opc.noarg ;CCF
3546 dw as.AND_CP_OR_SUB_XOR ;CP
3550 dw gen.opc.ED2 ;CPDR
3554 dw gen.opc.ED2 ;CPIR
3556 dw as.opc.noarg ;CPL
3558 dw as.opc.noarg ;DAA
3570 dw as.opc.noarg ;EXX
3572 dw as.opc.noarg ;HALT
3582 dw gen.opc.ED2 ;INDR
3586 dw gen.opc.ED2 ;INIR
3596 dw gen.opc.ED2 ;LDDR
3600 dw gen.opc.ED2 ;LDIR
3604 dw as.opc.noarg ;NOP
3606 dw as.AND_CP_OR_SUB_XOR ;OR
3608 dw gen.opc.ED2 ;OTDR
3610 dw gen.opc.ED2 ;OTIR
3614 dw gen.opc.ED2 ;OUTD
3616 dw gen.opc.ED2 ;OUTI
3620 dw as.POP_PUSH ;PUSH
3626 dw gen.opc.ED2 ;RETI
3628 dw gen.opc.ED2 ;RETN
3632 dw as.opc.noarg ;RLA
3636 dw as.opc.noarg ;RLCA
3642 dw as.opc.noarg ;RRA
3646 dw as.opc.noarg ;RRCA
3654 dw as.opc.noarg ;SCF
3664 dw as.AND_CP_OR_SUB_XOR ;SUB
3666 dw as.AND_CP_OR_SUB_XOR ;XOR
3673 dw gen.opc.ED2 ;OTDM
3675 dw gen.opc.ED2 ;OTDMR
3677 dw gen.opc.ED2 ;OTIM
3679 dw gen.opc.ED2 ;OTIMR
3690 ;-------------------------------------------------------------------------------
3718 call arg.addr_8bit ;
3722 call arg.addr_8bit ;
3755 call arg.IDX_displcmnt
3772 call test_paren_close
3839 call arg.IDX_displcmnt
3907 call test_paren_close
3915 call test_paren_close
3963 jr as.opc.noarg ;14ca
3971 call test_paren_close
3997 call test_paren_close
4029 call test_paren_close
4051 jr nc,as.AND_CP_OR_SUB_XOR
4073 jr nc,as.AND_CP_OR_SUB_XOR
4094 as.AND_CP_OR_SUB_XOR:
4109 call arg.IDX_displcmnt
4126 call arg.IDX_displcmnt
4156 call arg.IDX_displcmnt
4397 call arg.IDX_displcmnt
4625 ;-------------------------------------------------------------------------------
4626 ; >>L [startaddr] [endaddr]
4627 ; List disassembled code
4662 ;-------------------------------------------------------------------------------
4694 ;-------------------------------------------------------------------------------
4709 ;-------------------------------------------------------------------------------
4713 ld (disas_argtype),a
4714 call disas_get_instrlen
4725 ld a,(disas_argtype)
4726 ld hl,(disas_arg_16)
4740 ld (isprefix_ixiy),a
4759 ld (isprefix_ixiy),a
4770 ;-------------------------------------------------------------------------------
4798 ;-------------------------------------------------------------------------------
4799 ; DD/FD 3 byte (ix+d)/(iy+d)
4846 ;-------------------------------------------------------------------------------
4868 ;-------------------------------------------------------------------------------
4873 ld a,(isprefix_ixiy)
4884 ;-------------------------------------------------------------------------------
4905 ;-------------------------------------------------------------------------------
4962 ;-------------------------------------------------------------------------------
4963 ; 1 byte opcodes (no parameters)
4964 ; Format: db opcode, t_MNEMONICS-index
4983 ; Format: db mask, match, t_MNEMONICS-index
4984 ; dw argument formating fuction
4986 db 0c0h,040h,056h ;ld r,r
4988 db 0f8h,080h,003h ;add a,r
4990 db 0f8h,088h,000h ;adc a,r
4992 db 0f8h,090h,0c9h ;sub r
4994 db 0f8h,098h,0b7h ;sbc a,r
4996 db 0f8h,0a0h,006h ;and r
4998 db 0f8h,0a8h,0cch ;xor r
5000 db 0f8h,0b0h,06ch ;or r
5002 db 0f8h,0b8h,013h ;cp r
5004 db 0c7h,0c0h,08bh ;ret cc
5006 db 0c7h,0c7h,0b4h ;rst
5008 db 0ffh,0c9h,08bh ;ret
5010 db 0cfh,0c1h,081h ;pop rr
5012 db 0cfh,0c5h,084h ;push rr
5014 db 0ffh,0e3h,034h ;ex (sp),hl
5016 db 0ffh,0e9h,052h ;jp (hl)
5018 db 0ffh,0ebh,034h ;ex de,hl
5020 db 0ffh,0f9h,056h ;ld sp,hl
5022 db 0cfh,003h,041h ;inc rr
5024 db 0cfh,00bh,029h ;dec rr
5026 db 0c7h,004h,041h ;inc r
5028 db 0c7h,005h,029h ;dec r
5030 db 0ffh,008h,034h ;ex af,af'
5032 db 0cfh,009h,003h ;add hl,rr
5034 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
5036 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
5042 db 0c7h,006h,056h ;ld r,nn
5044 db 0ffh,0c6h,003h ;add a,nn
5046 db 0ffh,0ceh,000h ;adc a,nn
5048 db 0ffh,0d6h,0c9h ;sub a,nn
5050 db 0ffh,0deh,0b7h ;sbc a,nn
5052 db 0ffh,0e6h,006h ;and a,nn
5054 db 0ffh,0eeh,0cch ;xor nn
5056 db 0ffh,0f6h,06ch ;or nn
5058 db 0ffh,0feh,013h ;cp a,nn
5060 db 0ffh,010h,02eh ;djnz
5062 db 0ffh,018h,054h ;jr
5064 db 0e7h,020h,054h ;jr cc,
5066 db 0ffh,0d3h,076h ;out (nn),a
5068 db 0ffh,0dbh,03fh ;in a,(nn)
5074 db 0c7h,0c2h,052h ;jp cc,mn
5076 db 0c7h,0c4h,00ch ;call cc,mn
5078 db 0cfh,001h,056h ;ld ww,mn
5080 db 0ffh,0c3h,052h ;jp mn
5082 db 0ffh,0cdh,00ch ;call mn
5084 db 0ffh,022h,056h ;ld (mn),hl
5086 db 0ffh,02ah,056h ;ld hl,(mn)
5088 db 0ffh,032h,056h ;ld (mn),a
5090 db 0ffh,03ah,056h ;ld a,(mn)
5094 ; Prefix ED + 1 byte opcode, no arguments
5095 ; Format: opcode, t_MNEMONICS index
5126 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
5128 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
5130 db 0ffh,078h,03fh ;in r,(c) ;r=a
5132 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
5134 db 0f7h,061h,076h ;out (c),r ;r=h,l
5136 db 0ffh,079h,076h ;out (c),r ;r=a
5138 db 0cfh,042h,0b7h ;sbc hl,rr
5140 db 0cfh,04ah,000h ;adc hl,rr
5142 db 0ffh,046h,03dh ;im 0
5144 db 0ffh,056h,03dh ;im 1
5146 db 0ffh,05eh,03dh ;im 2
5148 db 0ffh,047h,056h ;ld i,a
5150 db 0ffh,057h,056h ;ld a,i
5152 db 0ffh,04fh,056h ;ld r,a
5154 db 0ffh,05fh,056h ;ld a,r
5156 db 0cfh,04ch,0d2h ;mlt rr
5158 db 0c7h,004h,0eeh ;tst r
5163 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
5165 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
5167 db 0ffh,038h,0cfh ;in0 a,(m)
5169 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
5171 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
5173 db 0ffh,039h,0e7h ;out0 (m),a
5175 db 0ffh,064h,0eeh ;tst m
5177 db 0ffh,074h,0f1h ;tstio m
5182 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
5184 db 0ffh,073h,056h ;ld (mn),sp
5186 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
5188 db 0ffh,07bh,056h ;ld sp,(mn)
5194 db 0f8h,000h,09bh ;rlc g
5196 db 0f8h,008h,0aah ;rrc g
5198 db 0f8h,010h,096h ;rl g
5200 db 0f8h,018h,0a5h ;rr g
5202 db 0f8h,020h,0c0h ;sla g
5204 db 0f8h,028h,0c3h ;sra g
5206 db 0f8h,038h,0c6h ;srl g
5208 db 0c0h,040h,009h ;bit b,g
5210 db 0c0h,080h,088h ;res b,g
5212 db 0c0h,0c0h,0bdh ;set b,g
5216 ;-------------------------------------------------------------------------------
5289 ld a,(isprefix_ixiy)
5335 ld (disas_argtype),a
5336 ld (disas_arg_16),hl
5432 ld a,(isprefix_ixiy)
5452 ld a,(isprefix_ixiy)
5485 ld a,(isprefix_ixiy)
5490 ld a,(isprefix_ixiy)
5522 ld a,(isprefix_ixiy)
5554 ;-------------------------------------------------------------------------------
5707 ;-------------------------------------------------------------------------------
5720 call disas_get_instrlen
5740 ;-------------------------------------------------------------------------------
5743 db 0ffh,0ddh,000h ;Prefix DD
5745 db 0ffh,0fdh,000h ;Prefix FD
5747 db 0ffh,0edh,000h ;Prefix ED
5751 db 0ffh,0cdh,000h ;call mn
5753 db 0ffh,0c3h,000h ;jp mn
5755 db 0ffh,0e9h,000h ;jp ()
5757 db 0ffh,0c9h,000h ;ret
5759 db 0ffh,0cfh,000h ;rst 8
5775 ;-------------------------------------------------------------------------------
5781 ld a,(trace_call_flag)
5846 ld a,(trace_call_flag)
5873 ld a,(trace_call_flag)
5883 ;-------------------------------------------------------------------------------
5885 ; >>C[N][J] W expression
5886 ; >>C[N][J] U expression
5887 ; trace over Calls [No list] [Jumps only] /.While./.Until.
5894 ;-------------------------------------------------------------------------------
5896 ; >>T[N][J] W expression
5897 ; >>T[N][J] U expression
5898 ; Trace [no List] [Jumps only] / .While. / .Until.
5905 ld (trace_call_flag),a
5921 call get_lastarg_def
5931 call bp_clr_temporary
5942 ld a,(trace_UW_flag)
5978 ld (trace_UW_flag),a
5993 ld (trace_UW_flag),a
6013 ;-------------------------------------------------------------------------------
6018 db 0 ;1=call, 0=trace
6020 db 0 ;0 or 'U' or 'W'
6028 ;-------------------------------------------------------------------------------
6049 current_cseg defl $ - current_cseg
6050 .phase current_phase + current_cseg
6053 LD SP,ldr_end+(stack-ddtz_base)
6054 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
6067 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
6068 ld bc,0108h ;init bit counter
6072 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
6076 INC DE ;size rounded up to next page boundary
6079 SBC HL,DE ;BDOS - size
6080 LD (BDOS+1),HL ;-> new BDOS entry
6095 ld b,c ;reload bit counter
6096 LD e,(HL) ;get next 8 relocation bits
6122 LD HL,conbuf+2-ddtz_base
6126 current_phase defl $
6130 ds EXPR_BUF_SIZE - ($ - expr_buf)
6133 ;-------------------------------------------------------------------------------
6189 symlen_cur: ;max length of symbols read so far
6196 ddtz_size equ $-ddtz_base
6199 ;-------------------------------------------------------------------------------