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
975 ; de: x (x shifted out, q shifted in)
977 ; hl: r (initially 0)
994 ex de,hl ;hl: q de: r
1093 jp z,EXPR_BRCKT ;0c35 [ expression ]
1095 jr z,fact_factstring
1253 add hl,hl ;0d0e hl *= 10
1306 ld hl,b_0x0DFD_start
1307 ld de,b_0x0E1D_start
1503 call skip_to_nextarg
1595 call skip_to_nextarg
1664 push hl ;save rom enable stat
1673 push hl ;save I register
1679 else ;NMOS Z80 design flaw
1680 call getiff ;return Carry set, if INTs are disabled.
1731 DB CR,LF,'Undefined opcode trap'
1898 call nz,prnt_cpustat
1908 ld sp,$stack ;11a2 set/restore user cpu state
1936 jp $go ;11c2 common ram, switch banks and go to user prog
2040 ld hl,b_0x132A_start
2146 ld hl,b_0x136C_start
2277 call get_lastarg_def
2320 call get_lastarg_def
2356 call skip_to_nextarg
2358 call get_lastarg_def
2388 call get_arg3 ;1490 get from, size, to
2426 push af ;14c9 save 'V' flag
2452 jr z,cmp_mem ;14ed validate?
2456 jp c,l173ch ;no parameters, print High and Max
2457 call skip_to_nextarg
2475 call out.hl ;1511 val
2477 call sub_0928h ;1517 -val
2479 call out.hl.dec ;151d dec
2481 call out.hl.decm ;1523 -dec
2483 call out.bin.w ;1529 bin
2589 db 0e6h ;15b8 and 037h (clear carry, skip next opc)
2594 call skip_to_nextarg
2750 ; Read Intel Hex File from console.
2753 call get_lastarg_def ;169e get offset from command line
2762 ld c,0 ;16b1 init checksum
2763 call i.gethexbyte ;16b3 record len
2765 call i.gethexbyte ;16b7 address high
2767 call i.gethexbyte ;16bb address low
2769 call i.gethexbyte ;16bf record type (ignored)
2771 and a ;16c3 record len == 0?
2782 djnz l16c6h ;16d2 repeat for record len
2783 call i.gethexbyte ;16d4 checksum
2786 jp nz,ERROR ;16d9 exit if checksum error
2787 jr w_recstart ;16dc next record
2824 ld de,TPA ;170a lowest allowed load address
2827 ld de,$stcka ;1713 highest allowed load address
2843 ld (hl),a ;173a store byte
2867 call get_lastarg_def
2925 ld hl,b_0x17EE_start
3581 ld a,b ;1a28 ld r,nn
3627 ld (iy+000h),a ;1a83 dd/fd
3629 ld (iy+002h),c ;1a8a displacement
3630 ld (iy+003h),l ;1a8d nn
3790 call skip_to_nextarg
3872 call skip_to_nextarg
3898 ld hl,b_0x1C97_start
3906 call skip_to_nextarg
3935 call skip_to_nextarg
4034 ld hl,b_0x1D80_start
4040 ld hl,b_0x1DA1_start
4242 call sub_1e12h ;1e97 get displacement
4289 call skip_to_nextarg
4308 call skip_to_nextarg
4397 ld hl,b_0x1F9B_start
4447 ld hl,b_0x2011_start
4522 ld hl,b_0x2200_start
4552 ld hl,b_0x218B_start
4556 ld hl,b_0x20ED_start
4560 ld hl,b_0x2108_start
4564 ld hl,b_0x21D2_start
4631 b_0x20ED_start: ; 1 byte opcodes (no parameters)
4660 b_0x2108_start: ; 1 byte opcodes
4661 defb 0c0h ;2108 ld r,r
4666 defb 0f8h ;210d add a,r
4671 defb 0f8h ;2112 adc a,r
4707 defb 0c0h ;2136 ret cc
4721 defb 0cfh ;2144 pop rr
4726 defb 0cfh ;2149 push rr
4731 defb 0ffh ;214e ex (sp),hl
4736 defb 0ffh ;2153 jp (hl)
4741 defb 0ffh ;2158 ex de,hl
4746 defb 0ffh ;215d ld sp,hl
4751 defb 0cfh ;2162 inc rr
4756 defb 0cfh ;2167 dec rr
4762 defb 0c7h ;216c inc r
4767 defb 0c7h ;2171 dec r
4772 defb 0ffh ;2176 ex af,af'
4777 defb 0cfh ;217b add hl,rr
4782 defb 0efh ;2180 ld (rr),a ;rr=bc,de
4787 defb 0efh ;2185 ld a,(rr) ;rr=bc,de
4794 b_0x218B_start: ; 2 byte opdodes
4795 defb 0c7h ;218b ld r,nn
4800 defb 0ffh ;2190 add a,nn
4805 defb 0ffh ;2195 adc a,nn
4810 defb 0ffh ;219a sub a,nn
4820 defb 0ffh ;21a4 and a,nn
4835 defb 0ffh ;21b3 cp a,nn
4840 defb 0ffh ;21b8 djnz
4850 defb 0e7h ;21c2 jr,cc
4856 defb 0d3h ;21c8 out (nn),a
4860 defb 0ffh ;21cc in a,(nn)
4867 b_0x21D2_start: ; 3 byte opcodes
4915 b_0x2200_start: ; prefix ED + 1 byte opcode
4918 defb 045h ;2202 retn
4920 defb 04dh ;2204 reti
4942 defb 0b0h ;221a ldir
4950 defb 0b8h ;2222 lddr
4958 defb 08bh ;222a otdm
4960 defb 09bh ;222c otdmr
4962 defb 083h ;222e otim
4964 defb 093h ;2230 otimr
4971 defb 0e7h ;2235 in r,(c) ;r=bcde
4976 defb 0f7h ;223a in r,(c) ;r=hl
4981 defb 0ffh ;223f in r,(c) ;r=a
4996 defb 0ffh ;224e out (c),r ;r=a
5001 defb 0cfh ;2253 sbc hl,rr
5006 defb 0cfh ;2258 adc hl,rr
5011 defb 0ffh ;225d im 0
5016 defb 0ffh ;2262 im 1
5021 defb 0ffh ;2267 im 2
5026 defb 0ffh ;226c ld i,a
5046 defb 0cfh ;2280 mlt rr
5051 defb 0c7h ;2285 tst r
5264 ld hl,b_0x2333_start
5281 ld hl,b_0x2354_start
5289 ld hl,b_0x1D80_start
5407 ld hl,b_0x2449_start
5519 ld hl,b_0x2538_start
5523 ld hl,b_0x253B_start
5770 ld hl,b_0x2717_start
6005 call get_lastarg_def
6135 ;------------------------------------------
6137 ;------------------------------------------
6144 ; The following 2 params are changeable by user.
6145 ; Should these moved to top ram?
6148 rst DDTZRSTVEC ;rst used by ddtz
6149 ddtei: ei ;ints enabled/disabled while ddtz is running
6246 ;------------------------------------------
6248 .phase sysram_start+bs$stack$size
6250 $stcka equ $ - bs$stack$size
6258 reg.l2: db 0 ; 0fe50h
6259 reg.h2: db 0 ; 0fe51h
6260 reg.e2: db 0 ; 0fe52h
6261 reg.d2: db 0 ; 0fe53h
6262 reg.c2: db 0 ; 0fe54h
6263 reg.b2: db 0 ; 0fe55h
6264 reg.f2: db 0 ; 0fe56h
6265 reg.a2: db 0 ; 0fe57h
6267 reg.i: db high ivtab
6268 reg.iy: dw 0 ; 0fe5ah
6269 reg.ix: dw 0 ; 0fe5ch
6270 reg.e: db 0 ; 0fe5eh
6271 reg.d: db 0 ; 0fe5fh
6272 reg.c: db 0 ; 0fe60h
6273 reg.b: db 0 ; 0fe61h
6275 udcntl: db CWAITIO ; 0fe62h (mem-, io- wait)
6276 uromen: db ROM_DIS ; 0fe63h
6280 ucbar: db USR$CBAR ; 0fe65h
6285 reg.f: db 0 ; 0fe66h
6286 reg.a: db 0 ; 0fe67h
6287 reg.l: db 0 ; 0fe68h
6288 reg.h: db 0 ; 0fe69h
6289 reg.sp: dw TOPRAM ; 0fe6ah
6293 out (000h),a ;064c fe6c
6309 db 0C3h ;jp TPA ;065f feff ($+1): reg.pc
6314 ld (reg.l),hl ;0662 fe82: bpent:
6322 ;;; TODO: cbar on trap?
6338 ld a,CWAITROM+CWAITIO
6350 out (000h),a ;0692 feb2