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)
1086 ;-------------------------------------------------------------------------------
1134 jr z,fact_factstring
1141 ;-------------------------------------------------------------------------------
1244 ld hl,ddtz_base ;symtbl start
1264 pop hl ;inpsym ptr (discard)
1286 fs_cont: ;start over
1295 ;-------------------------------------------------------------------------------
1403 ;-------------------------------------------------------------------------------
1451 ld hl,t_flag_names+7
1552 ;-------------------------------------------------------------------------------
1553 ; > G [startaddr] [;breakp..]
1554 ; Go [to start] [with temporary breakpoints]
1558 ld (trace_call_flag),a
1559 ld (bp_p_cpu_flag),a
1574 ;-------------------------------------------------------------------------------
1580 ld (pbl_loop_adr),hl
1593 ld hl,(pbl_loop_adr)
1603 call bp_clr_condition
1608 ;-------------------------------------------------------------------------------
1610 ; display all breakpoints
1611 ; > B breakp [breakp..]
1614 ; clear all breakpoints
1615 ; > BX address [address..]
1619 ; [R] expression [I condition]
1656 call bp_clr_condition
1701 ;-------------------------------------------------------------------------------
1702 ; Add break points to list
1703 ; A = 1 Permanent (B command)
1704 ; A = 2 Temporary (G command)
1725 call bp_get_freeslot
1732 call bp_get_condition
1789 ld (hl),c ; trailing 0
1795 ;-------------------------------------------------------------------------------
1796 ; Breakpoint handling routine.
1830 call inchar ;Keyboard hit?
1838 call bp_clr_temporary
1851 ld (bp_p_cpu_flag),a
1895 ld (bp_p_cpu_flag),a
1940 call bp_get_freeslot
1983 ;-------------------------------------------------------------------------------
1988 ld a,(bp_p_cpu_flag)
2018 ;-------------------------------------------------------------------------------
2072 ;-------------------------------------------------------------------------------
2074 ; examine all Y variables
2076 ; examine (and substitute) an Y variable
2104 call c,p_align_@_sym
2126 ;-------------------------------------------------------------------------------
2128 ; eXamine (display) all cpu registers and
2129 ; the instruction at the current program counter
2131 ; eXamine (and substitute) a register
2361 ;-------------------------------------------------------------------------------
2367 call get_lastarg_def
2401 ;-------------------------------------------------------------------------------
2403 ; examine (substitute) displacement register @
2415 ;-------------------------------------------------------------------------------
2417 ; Input a byte from port
2423 call get_lastarg_def
2435 ;-------------------------------------------------------------------------------
2437 ; Output a byte to a port
2449 call get_lastarg_def
2457 ;-------------------------------------------------------------------------------
2458 ; > Vstartaddr endaddr targetaddr
2459 ; Verify (compare) two memory areas
2492 ;-------------------------------------------------------------------------------
2493 ; > M[V] startaddr endaddr destaddr
2494 ; Move memory [and verify]
2516 db 01h ;swallow ldir instruction (ld bc,...)
2526 ;-------------------------------------------------------------------------------
2528 ; display Highest load address of last filed loaded, Maximum "High"
2529 ; off all loaded files, and Top address of available memory
2531 ; display symbol list
2533 ; evaluate expression and display result in hex, decimal and other formats
2534 ; > H expression expression
2535 ; display sum und difference of expressions
2621 ;-------------------------------------------------------------------------------
2622 ; > Q[J] startaddr endaddr bytes
2623 ; Query memory for a byte string [Justified]
2664 ;-------------------------------------------------------------------------------
2665 ; > Z startaddr endaddr bytes
2666 ; Zap (fill) memory with a byte string
2718 db 0e6h ; and 037h (clear carry)
2781 ;-------------------------------------------------------------------------------
2782 ; >>D [startaddr] [endaddr]
2783 ; Display memory in hex and ASCII
2853 ;-------------------------------------------------------------------------------
2855 ; specifiy filenames and command line
2986 ;-------------------------------------------------------------------------------
3004 ;-------------------------------------------------------------------------------
3129 ;-------------------------------------------------------------------------------
3130 ; > R [displacement]
3131 ; Read a binary or hex file and or symbol file [add displacement]
3135 call get_lastarg_def
3175 call read_byte ; RECORD MARK
3180 call read_hexchar ; RECLEN
3182 call read_hexchar ; LOAD ADDR H
3184 call read_hexchar ; LOAD ADDR L
3189 call read_hexchar ; RECTYP
3191 call read_hexchar ; DATA
3200 call read_hexchar ; CHKSUM
3217 db 'SYMBOLS',CR,LF+80h
3232 call read_hexbyte0 ; symval H
3234 call read_hexbyte ; symval L
3240 rs_3: call read_byte
3248 ld b,0 ; setup symlen
3251 call read_byte ; next char of symbol name
3252 call test_sym_char ; valid char?
3269 call test_symterm_ch
3312 ; test for valid character for symbols
3325 ret c ; cy == 1 --> z == 0
3330 ; check if char is in [0..9,?,@,A..Z,a..z]
3331 ; return cy if invalid
3332 ; return nc if valid alfanumeric char
3366 ;-------------------------------------------------------------------------------
3385 ;-------------------------------------------------------------------------------
3386 ; > Wstartaddr endaddr
3387 ; Write a file to disk
3421 ld de,080h ; DMA_BUF
3450 ;-------------------------------------------------------------------------------
3452 ; Assemble Zilog Z180 mnemonics
3456 call get_lastarg_def
3486 call nz,asemble_line
3523 ;-------------------------------------------------------------------------------
3530 dw as.AND_CP_OR_SUB_XOR ;AND
3536 dw as.opc.noarg ;CCF
3538 dw as.AND_CP_OR_SUB_XOR ;CP
3542 dw gen.opc.ED2 ;CPDR
3546 dw gen.opc.ED2 ;CPIR
3548 dw as.opc.noarg ;CPL
3550 dw as.opc.noarg ;DAA
3562 dw as.opc.noarg ;EXX
3564 dw as.opc.noarg ;HALT
3574 dw gen.opc.ED2 ;INDR
3578 dw gen.opc.ED2 ;INIR
3588 dw gen.opc.ED2 ;LDDR
3592 dw gen.opc.ED2 ;LDIR
3596 dw as.opc.noarg ;NOP
3598 dw as.AND_CP_OR_SUB_XOR ;OR
3600 dw gen.opc.ED2 ;OTDR
3602 dw gen.opc.ED2 ;OTIR
3606 dw gen.opc.ED2 ;OUTD
3608 dw gen.opc.ED2 ;OUTI
3612 dw as.POP_PUSH ;PUSH
3618 dw gen.opc.ED2 ;RETI
3620 dw gen.opc.ED2 ;RETN
3624 dw as.opc.noarg ;RLA
3628 dw as.opc.noarg ;RLCA
3634 dw as.opc.noarg ;RRA
3638 dw as.opc.noarg ;RRCA
3646 dw as.opc.noarg ;SCF
3656 dw as.AND_CP_OR_SUB_XOR ;SUB
3658 dw as.AND_CP_OR_SUB_XOR ;XOR
3665 dw gen.opc.ED2 ;OTDM
3667 dw gen.opc.ED2 ;OTDMR
3669 dw gen.opc.ED2 ;OTIM
3671 dw gen.opc.ED2 ;OTIMR
3682 ;-------------------------------------------------------------------------------
3710 call arg.addr_8bit ;
3714 call arg.addr_8bit ;
3747 call arg.IDX_displcmnt
3764 call test_paren_close
3831 call arg.IDX_displcmnt
3899 call test_paren_close
3907 call test_paren_close
3955 jr as.opc.noarg ;14ca
3963 call test_paren_close
3989 call test_paren_close
4021 call test_paren_close
4043 jr nc,as.AND_CP_OR_SUB_XOR
4065 jr nc,as.AND_CP_OR_SUB_XOR
4086 as.AND_CP_OR_SUB_XOR:
4101 call arg.IDX_displcmnt
4118 call arg.IDX_displcmnt
4148 call arg.IDX_displcmnt
4389 call arg.IDX_displcmnt
4617 ;-------------------------------------------------------------------------------
4618 ; >>L [startaddr] [endaddr]
4619 ; List disassembled code
4654 ;-------------------------------------------------------------------------------
4686 ;-------------------------------------------------------------------------------
4701 ;-------------------------------------------------------------------------------
4705 ld (disas_argtype),a
4706 call disas_get_instrlen
4717 ld a,(disas_argtype)
4718 ld hl,(disas_arg_16)
4732 ld (isprefix_ixiy),a
4751 ld (isprefix_ixiy),a
4762 ;-------------------------------------------------------------------------------
4790 ;-------------------------------------------------------------------------------
4791 ; DD/FD 3 byte (ix+d)/(iy+d)
4838 ;-------------------------------------------------------------------------------
4860 ;-------------------------------------------------------------------------------
4865 ld a,(isprefix_ixiy)
4876 ;-------------------------------------------------------------------------------
4897 ;-------------------------------------------------------------------------------
4954 ;-------------------------------------------------------------------------------
4955 ; 1 byte opcodes (no parameters)
4956 ; Format: db opcode, t_MNEMONICS-index
4975 ; Format: db mask, match, t_MNEMONICS-index
4976 ; dw argument formating fuction
4978 db 0c0h,040h,056h ;ld r,r
4980 db 0f8h,080h,003h ;add a,r
4982 db 0f8h,088h,000h ;adc a,r
4984 db 0f8h,090h,0c9h ;sub r
4986 db 0f8h,098h,0b7h ;sbc a,r
4988 db 0f8h,0a0h,006h ;and r
4990 db 0f8h,0a8h,0cch ;xor r
4992 db 0f8h,0b0h,06ch ;or r
4994 db 0f8h,0b8h,013h ;cp r
4996 db 0c7h,0c0h,08bh ;ret cc
4998 db 0c7h,0c7h,0b4h ;rst
5000 db 0ffh,0c9h,08bh ;ret
5002 db 0cfh,0c1h,081h ;pop rr
5004 db 0cfh,0c5h,084h ;push rr
5006 db 0ffh,0e3h,034h ;ex (sp),hl
5008 db 0ffh,0e9h,052h ;jp (hl)
5010 db 0ffh,0ebh,034h ;ex de,hl
5012 db 0ffh,0f9h,056h ;ld sp,hl
5014 db 0cfh,003h,041h ;inc rr
5016 db 0cfh,00bh,029h ;dec rr
5018 db 0c7h,004h,041h ;inc r
5020 db 0c7h,005h,029h ;dec r
5022 db 0ffh,008h,034h ;ex af,af'
5024 db 0cfh,009h,003h ;add hl,rr
5026 db 0efh,002h,056h ;ld (rr),a ;rr=bc,de
5028 db 0efh,00ah,056h ;ld a,(rr) ;rr=bc,de
5034 db 0c7h,006h,056h ;ld r,nn
5036 db 0ffh,0c6h,003h ;add a,nn
5038 db 0ffh,0ceh,000h ;adc a,nn
5040 db 0ffh,0d6h,0c9h ;sub a,nn
5042 db 0ffh,0deh,0b7h ;sbc a,nn
5044 db 0ffh,0e6h,006h ;and a,nn
5046 db 0ffh,0eeh,0cch ;xor nn
5048 db 0ffh,0f6h,06ch ;or nn
5050 db 0ffh,0feh,013h ;cp a,nn
5052 db 0ffh,010h,02eh ;djnz
5054 db 0ffh,018h,054h ;jr
5056 db 0e7h,020h,054h ;jr cc,
5058 db 0ffh,0d3h,076h ;out (nn),a
5060 db 0ffh,0dbh,03fh ;in a,(nn)
5066 db 0c7h,0c2h,052h ;jp cc,mn
5068 db 0c7h,0c4h,00ch ;call cc,mn
5070 db 0cfh,001h,056h ;ld ww,mn
5072 db 0ffh,0c3h,052h ;jp mn
5074 db 0ffh,0cdh,00ch ;call mn
5076 db 0ffh,022h,056h ;ld (mn),hl
5078 db 0ffh,02ah,056h ;ld hl,(mn)
5080 db 0ffh,032h,056h ;ld (mn),a
5082 db 0ffh,03ah,056h ;ld a,(mn)
5086 ; Prefix ED + 1 byte opcode, no arguments
5087 ; Format: opcode, t_MNEMONICS index
5118 db 0e7h,040h,03fh ;in r,(c) ;r=b,c,d,e
5120 db 0f7h,060h,03fh ;in r,(c) ;r=h,l
5122 db 0ffh,078h,03fh ;in r,(c) ;r=a
5124 db 0e7h,041h,076h ;out (c),r ;r=b,c,d,e
5126 db 0f7h,061h,076h ;out (c),r ;r=h,l
5128 db 0ffh,079h,076h ;out (c),r ;r=a
5130 db 0cfh,042h,0b7h ;sbc hl,rr
5132 db 0cfh,04ah,000h ;adc hl,rr
5134 db 0ffh,046h,03dh ;im 0
5136 db 0ffh,056h,03dh ;im 1
5138 db 0ffh,05eh,03dh ;im 2
5140 db 0ffh,047h,056h ;ld i,a
5142 db 0ffh,057h,056h ;ld a,i
5144 db 0ffh,04fh,056h ;ld r,a
5146 db 0ffh,05fh,056h ;ld a,r
5148 db 0cfh,04ch,0d2h ;mlt rr
5150 db 0c7h,004h,0eeh ;tst r
5155 db 0e7h,000h,0cfh ;in0 r,(m) ;r=b,c,d,e
5157 db 0f7h,020h,0cfh ;in0 r,(m) ;r=h,l
5159 db 0ffh,038h,0cfh ;in0 a,(m)
5161 db 0e7h,001h,0e7h ;out0 (m),r ;r=b,c,d,e
5163 db 0f7h,021h,0e7h ;out0 (m),r ;r=h,l
5165 db 0ffh,039h,0e7h ;out0 (m),a
5167 db 0ffh,064h,0eeh ;tst m
5169 db 0ffh,074h,0f1h ;tstio m
5174 db 0efh,043h,056h ;ld (mn),ww ;ww=bc,de
5176 db 0ffh,073h,056h ;ld (mn),sp
5178 db 0efh,04bh,056h ;ld ww,(mn) ;ww=bc,de
5180 db 0ffh,07bh,056h ;ld sp,(mn)
5186 db 0f8h,000h,09bh ;rlc g
5188 db 0f8h,008h,0aah ;rrc g
5190 db 0f8h,010h,096h ;rl g
5192 db 0f8h,018h,0a5h ;rr g
5194 db 0f8h,020h,0c0h ;sla g
5196 db 0f8h,028h,0c3h ;sra g
5198 db 0f8h,038h,0c6h ;srl g
5200 db 0c0h,040h,009h ;bit b,g
5202 db 0c0h,080h,088h ;res b,g
5204 db 0c0h,0c0h,0bdh ;set b,g
5208 ;-------------------------------------------------------------------------------
5280 ld a,(isprefix_ixiy)
5330 ld (disas_argtype),a
5331 ld (disas_arg_16),hl
5440 ld a,(isprefix_ixiy)
5460 ld a,(isprefix_ixiy)
5482 ld a,(isprefix_ixiy)
5487 ld a,(isprefix_ixiy)
5517 ld a,(isprefix_ixiy)
5549 ;-------------------------------------------------------------------------------
5702 ;-------------------------------------------------------------------------------
5715 call disas_get_instrlen
5730 call c,bp_trace_enter
5735 ;-------------------------------------------------------------------------------
5738 db 0ffh,0ddh,000h ;Prefix DD
5740 db 0ffh,0fdh,000h ;Prefix FD
5742 db 0ffh,0edh,000h ;Prefix ED
5746 db 0ffh,0cdh,000h ;call mn
5748 db 0ffh,0c3h,000h ;jp mn
5750 db 0ffh,0e9h,000h ;jp ()
5752 db 0ffh,0c9h,000h ;ret
5754 db 0ffh,0cfh,000h ;rst 8
5756 db 0c7h,0c7h,000h ;rst n
5758 db 0c7h,0c4h,000h ;call cc,mn
5760 db 0f7h,010h,000h ;djnz d; jr d
5762 db 0e7h,020h,000h ;jr cc,d
5764 db 0c7h,0c2h,000h ;jp cc,mn
5766 db 0c7h,0c0h,000h ;ret cc
5770 ;-------------------------------------------------------------------------------
5771 ; call mn call cc,mn
5776 ld a,(trace_call_flag)
5815 cp 0e9h ; jp (ix); jp (iy)
5851 ld a,(trace_call_flag)
5879 ld a,(trace_call_flag)
5886 ;-------------------------------------------------------------------------------
5888 ; >>C[N][J] W expression
5889 ; >>C[N][J] U expression
5890 ; trace over Calls [No list] [Jumps only] /.While./.Until.
5897 ;-------------------------------------------------------------------------------
5899 ; >>T[N][J] W expression
5900 ; >>T[N][J] U expression
5901 ; Trace [no List] [Jumps only] / .While. / .Until.
5908 ld (trace_call_flag),a
5922 jr z,tc_save_uw_expr_ptr
5923 ld hl,1 ;default: 1 step
5924 call get_lastarg_def
5925 tc_save_uw_expr_ptr:
5926 ld (trace_cnt_or_ptr),hl
5928 ld (bp_p_cpu_flag),a
5934 call bp_clr_temporary
5945 ld a,(trace_UW_flag) ;0 or 'U' or 'W'
5947 jr z,tc_cnt ;flag is 0, check for step count.
5948 ld de,(trace_cnt_or_ptr)
5954 ld hl,trace_UW_flag ;'U' or 'W'
5956 bit 1,a ;'U' = 55H, 'W' = 57H
5958 do_break0: ;print registers and go to main loop
5962 ld hl,(trace_cnt_or_ptr)
5964 ld (trace_cnt_or_ptr),hl
5973 ld a,(bp_p_cpu_flag)
5975 ld (bp_p_cpu_flag),a
5982 ld (trace_UW_flag),a
5997 ld (trace_UW_flag),a
6017 ;-------------------------------------------------------------------------------
6022 ;-------------------------------------------------------------------------------
6027 db 0 ;1=call, 0=trace
6029 db 0 ;0 or 'U' or 'W'
6051 current_cseg defl $ - current_cseg
6052 .phase current_phase + current_cseg
6055 LD SP,ldr_end+(stack-ddtz_base)
6056 LD DE,signon ;ldr_end+(expr_buf-ddtz_base)
6069 LD HL,ldr_end+ddtz_size ;start of reloc bitmap
6070 ld bc,0108h ;init bit counter
6074 LD (ldr_end+(ddtz_bdos+1-ddtz_base)),HL
6078 INC DE ;size rounded up to next page boundary
6081 SBC HL,DE ;BDOS - size
6082 LD (BDOS+1),HL ;-> new BDOS entry
6097 ld b,c ;reload bit counter
6098 LD e,(HL) ;get next 8 relocation bits
6124 LD HL,conbuf+2-ddtz_base
6128 current_phase defl $
6132 ds EXPR_BUF_SIZE - ($ - expr_buf)
6135 ;-------------------------------------------------------------------------------
6191 symlen_cur: ;max length of symbols read so far
6198 ddtz_size equ $-ddtz_base
6201 ;-------------------------------------------------------------------------------