4 extrn ?const,?conin,?cono
29 MEMDUMP_CNT equ 16 ;mem dump bytes per line
30 BP_CNT equ 12 ;number of breakbpoints
33 ;--------------------------------------------------
36 ; copy code to common memory and execute it there
43 ; mark end of common code snippet
63 ;----------------------------------------------------------
66 DB 'DDT/Z - HD64180 (ROM)'
70 DB 'DDT/Z180 (ROM) Commands:',CR,LF
71 DB '> @ examine/substitute the displacement register @',CR,LF
72 DB '> A [address] Assemble',CR,LF
73 DB '> B[X] display [or clear] all Breakpoints',CR,LF
74 DB ' B breakp [:count] [breakp..] set Breakpoints',CR,LF
75 DB ' BX address [address..] clear Breakpoints',CR,LF
76 DB '>>C[N][J] [count] trace over Calls [No list] [Jumps only]',CR,LF
77 DB ' C[N][J] W|U expression trace over Calls While|Until ...',CR,LF
78 DB '>>D [startadr] [endadr] Display memory in hex and ascii',CR,LF
79 DB '> G [startadr] [;breakp..] Go [to start] [temporary breakpoints]',CR,LF
80 DB '> H [expression [expression]] compute expressions / show High/max load adr.',CR,LF
81 DB '>>I [port] Input a byte from port',CR,LF
82 DB '>>L [startadr] [endadr] List disassembled code',CR,LF
83 DB '> M[V] startadr endadr destadr Move memory [and verify]',CR,LF
84 DB '>>O [byte] [port] Output a byte to port',CR,LF
85 DB '> Q[J] startadr endadr bytes Qery memory for byte string [Justified]',CR,LF
86 DB '> R [displacement] Read intel hex from console [add displacemt]',CR,LF
87 DB '> S address Substitute memory',CR,LF
88 DB '>>T[N][J] [count] Trace [No list] [Jumps only] [count steps]',CR,LF
89 DB ' T[N][J] W|U expression Trace While|Until expression',CR,LF
90 DB '> V startadr endadr destadr Verify (compare) two memory areas',CR,LF
91 DB '> X[register] eXamine [and substitute] registers',CR,LF
92 DB '> Y[0..9] eXamine [and substitute] Y variables',CR,LF
93 DB '> Z startadr endadr bytes Zap (fill) memory with a byte string',CR,LF
98 ld a,(wstrtflg) ;check warm start flag
105 ld bc,topcodend-topcodbeg
168 defw CMD.B ;Breakpoint
184 defw CMD.R ;Read Intel Hex
185 defw CMD.S ;Substitute
191 defw CMD.Y ;eXamine Y Registers
192 defw CMD.Z ;Zap (fill) memory
271 jr z,inl_e ;Accept line
273 jr z,inl_e ;Accept line
276 call DELC ;Delete Char
281 call DELC ;Delete Char
286 call DELL ;Delete Line
296 ld a,'^' ;Controll characters
648 db 3eh ;0a26 ld a,0c5h
735 db 0e6h ;0a87 and 037h (clear carry)
860 ld hl,tab_func_eqlege
969 ex de,hl ;de = x, hl = y
1088 jp z,EXPR_BRCKT ;0c35 [ expression ]
1090 jr z,fact_factstring
1248 add hl,hl ;0d0e hl *= 10
1301 ld hl,b_0x0DFD_start
1302 ld de,b_0x0E1D_start
1498 call skip_to_nextarg
1590 call skip_to_nextarg
1659 push hl ;save rom enable stat
1668 push hl ;save I register
1674 else ;NMOS Z80 design flaw
1675 call getiff ;return Carry set, if INTs are disabled.
1726 DB CR,LF,'Undefined opcode trap'
1893 call nz,prnt_cpustat
1903 ld sp,$stack ;11a2 set/restore user cpu state
1931 jp $go ;11c2 common ram, switch banks and go to user prog
2035 ld hl,b_0x132A_start
2141 ld hl,b_0x136C_start
2272 call get_lastarg_def
2315 call get_lastarg_def
2351 call skip_to_nextarg
2353 call get_lastarg_def
2383 call get_arg3 ;1490 get from, size, to
2421 push af ;14c9 save 'V' flag
2447 jr z,cmp_mem ;14ed validate?
2452 call skip_to_nextarg
2470 call out.hl ;1511 val
2472 call sub_0928h ;1517 -val
2474 call out.hl.dec ;151d dec
2476 call out.hl.decm ;1523 -dec
2478 call out.bin.w ;1529 bin
2584 db 0e6h ;15b8 and 037h (clear carry, skip next opc)
2589 call skip_to_nextarg
2745 ; Read Intel Hex File from console.
2748 call get_lastarg_def ;169e get offset from command line
2757 ld c,0 ;16b1 init checksum
2758 call i.gethexbyte ;16b3 record len
2760 call i.gethexbyte ;16b7 address high
2762 call i.gethexbyte ;16bb address low
2764 call i.gethexbyte ;16bf record type (ignored)
2766 and a ;16c3 record len == 0?
2777 djnz l16c6h ;16d2 repeat for record len
2778 call i.gethexbyte ;16d4 checksum
2781 jp nz,ERROR ;16d9 exit if checksum error
2782 jr w_recstart ;16dc next record
2819 ld de,TPA ;170a lowest allowed load address
2822 ld de,$stcka ;1713 highest allowed load address
2838 ld (hl),a ;173a store byte
2862 call get_lastarg_def
2920 ld hl,b_0x17EE_start
3576 ld a,b ;1a28 ld r,nn
3622 ld (iy+000h),a ;1a83 dd/fd
3624 ld (iy+002h),c ;1a8a displacement
3625 ld (iy+003h),l ;1a8d nn
3785 call skip_to_nextarg
3867 call skip_to_nextarg
3893 ld hl,b_0x1C97_start
3901 call skip_to_nextarg
3930 call skip_to_nextarg
4029 ld hl,b_0x1D80_start
4035 ld hl,b_0x1DA1_start
4237 call sub_1e12h ;1e97 get displacement
4284 call skip_to_nextarg
4303 call skip_to_nextarg
4392 ld hl,b_0x1F9B_start
4442 ld hl,b_0x2011_start
4517 ld hl,b_0x2200_start
4547 ld hl,b_0x218B_start
4551 ld hl,b_0x20ED_start
4555 ld hl,b_0x2108_start
4559 ld hl,b_0x21D2_start
4626 b_0x20ED_start: ; 1 byte opcodes (no parameters)
4655 b_0x2108_start: ; 1 byte opcodes
4656 defb 0c0h ;2108 ld r,r
4661 defb 0f8h ;210d add a,r
4666 defb 0f8h ;2112 adc a,r
4702 defb 0c0h ;2136 ret cc
4716 defb 0cfh ;2144 pop rr
4721 defb 0cfh ;2149 push rr
4726 defb 0ffh ;214e ex (sp),hl
4731 defb 0ffh ;2153 jp (hl)
4736 defb 0ffh ;2158 ex de,hl
4741 defb 0ffh ;215d ld sp,hl
4746 defb 0cfh ;2162 inc rr
4751 defb 0cfh ;2167 dec rr
4757 defb 0c7h ;216c inc r
4762 defb 0c7h ;2171 dec r
4767 defb 0ffh ;2176 ex af,af'
4772 defb 0cfh ;217b add hl,rr
4777 defb 0efh ;2180 ld (rr),a ;rr=bc,de
4782 defb 0efh ;2185 ld a,(rr) ;rr=bc,de
4789 b_0x218B_start: ; 2 byte opdodes
4790 defb 0c7h ;218b ld r,nn
4795 defb 0ffh ;2190 add a,nn
4800 defb 0ffh ;2195 adc a,nn
4805 defb 0ffh ;219a sub a,nn
4815 defb 0ffh ;21a4 and a,nn
4830 defb 0ffh ;21b3 cp a,nn
4835 defb 0ffh ;21b8 djnz
4845 defb 0e7h ;21c2 jr,cc
4851 defb 0d3h ;21c8 out (nn),a
4855 defb 0ffh ;21cc in a,(nn)
4862 b_0x21D2_start: ; 3 byte opcodes
4910 b_0x2200_start: ; prefix ED + 1 byte opcode
4913 defb 045h ;2202 retn
4915 defb 04dh ;2204 reti
4937 defb 0b0h ;221a ldir
4945 defb 0b8h ;2222 lddr
4953 defb 08bh ;222a otdm
4955 defb 09bh ;222c otdmr
4957 defb 083h ;222e otim
4959 defb 093h ;2230 otimr
4966 defb 0e7h ;2235 in r,(c) ;r=bcde
4971 defb 0f7h ;223a in r,(c) ;r=hl
4976 defb 0ffh ;223f in r,(c) ;r=a
4991 defb 0ffh ;224e out (c),r ;r=a
4996 defb 0cfh ;2253 sbc hl,rr
5001 defb 0cfh ;2258 adc hl,rr
5006 defb 0ffh ;225d im 0
5011 defb 0ffh ;2262 im 1
5016 defb 0ffh ;2267 im 2
5021 defb 0ffh ;226c ld i,a
5041 defb 0cfh ;2280 mlt rr
5046 defb 0c7h ;2285 tst r
5259 ld hl,b_0x2333_start
5276 ld hl,b_0x2354_start
5284 ld hl,b_0x1D80_start
5402 ld hl,b_0x2449_start
5514 ld hl,b_0x2538_start
5518 ld hl,b_0x253B_start
5765 ld hl,b_0x2717_start
6000 call get_lastarg_def
6130 ;------------------------------------------
6132 ;------------------------------------------
6139 ; The following 2 params are changeable by user.
6140 ; Should these moved to top ram?
6143 rst DDTZRSTVEC ;rst used by ddtz
6144 ddtei: ei ;ints enabled/disabled while ddtz is running
6241 ;------------------------------------------
6243 .phase sysram_start+stacksize
6245 $stcka equ $ - stacksize
6253 reg.l2: db 0 ; 0fe50h
6254 reg.h2: db 0 ; 0fe51h
6255 reg.e2: db 0 ; 0fe52h
6256 reg.d2: db 0 ; 0fe53h
6257 reg.c2: db 0 ; 0fe54h
6258 reg.b2: db 0 ; 0fe55h
6259 reg.f2: db 0 ; 0fe56h
6260 reg.a2: db 0 ; 0fe57h
6262 reg.i: db high ivtab
6263 reg.iy: dw 0 ; 0fe5ah
6264 reg.ix: dw 0 ; 0fe5ch
6265 reg.e: db 0 ; 0fe5eh
6266 reg.d: db 0 ; 0fe5fh
6267 reg.c: db 0 ; 0fe60h
6268 reg.b: db 0 ; 0fe61h
6270 udcntl: db CWAITIO ; 0fe62h (mem-, io- wait)
6271 uromen: db ROM_DIS ; 0fe63h
6275 ucbar: db USR$CBAR ; 0fe65h
6280 reg.f: db 0 ; 0fe66h
6281 reg.a: db 0 ; 0fe67h
6282 reg.l: db 0 ; 0fe68h
6283 reg.h: db 0 ; 0fe69h
6284 reg.sp: dw TOPRAM ; 0fe6ah
6288 out (000h),a ;064c fe6c
6304 db 0C3h ;jp TPA ;065f feff ($+1): reg.pc
6309 ld (reg.l),hl ;0662 fe82: bpent:
6317 ;;; TODO: cbar on trap?
6333 ld a,CWAITROM+CWAITIO
6345 out (000h),a ;0692 feb2