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
1087 jp z,EXPR_BRCKT ;0c35 [ expression ]
1089 jr z,fact_factstring
1247 add hl,hl ;0d0e hl *= 10
1300 ld hl,b_0x0DFD_start
1301 ld de,b_0x0E1D_start
1497 call skip_to_nextarg
1589 call skip_to_nextarg
1658 push hl ;save rom enable stat
1667 push hl ;save I register
1673 else ;NMOS Z80 design flaw
1674 call getiff ;return Carry set, if INTs are disabled.
1725 DB CR,LF,'Undefined opcode trap'
1892 call nz,prnt_cpustat
1902 ld sp,$stack ;11a2 set/restore user cpu state
1930 jp $go ;11c2 common ram, switch banks and go to user prog
2034 ld hl,b_0x132A_start
2140 ld hl,b_0x136C_start
2271 call get_lastarg_def
2314 call get_lastarg_def
2350 call skip_to_nextarg
2352 call get_lastarg_def
2382 call get_arg3 ;1490 get from, size, to
2420 push af ;14c9 save 'V' flag
2446 jr z,cmp_mem ;14ed validate?
2451 call skip_to_nextarg
2469 call out.hl ;1511 val
2471 call sub_0928h ;1517 -val
2473 call out.hl.dec ;151d dec
2475 call out.hl.decm ;1523 -dec
2477 call out.bin.w ;1529 bin
2583 db 0e6h ;15b8 and 037h (clear carry, skip next opc)
2588 call skip_to_nextarg
2744 ; Read Intel Hex File from console.
2747 call get_lastarg_def ;169e get offset from command line
2756 ld c,0 ;16b1 init checksum
2757 call i.gethexbyte ;16b3 record len
2759 call i.gethexbyte ;16b7 address high
2761 call i.gethexbyte ;16bb address low
2763 call i.gethexbyte ;16bf record type (ignored)
2765 and a ;16c3 record len == 0?
2776 djnz l16c6h ;16d2 repeat for record len
2777 call i.gethexbyte ;16d4 checksum
2780 jp nz,ERROR ;16d9 exit if checksum error
2781 jr w_recstart ;16dc next record
2818 ld de,TPA ;170a lowest allowed load address
2821 ld de,$stcka ;1713 highest allowed load address
2837 ld (hl),a ;173a store byte
2861 call get_lastarg_def
2919 ld hl,b_0x17EE_start
3575 ld a,b ;1a28 ld r,nn
3621 ld (iy+000h),a ;1a83 dd/fd
3623 ld (iy+002h),c ;1a8a displacement
3624 ld (iy+003h),l ;1a8d nn
3784 call skip_to_nextarg
3866 call skip_to_nextarg
3892 ld hl,b_0x1C97_start
3900 call skip_to_nextarg
3929 call skip_to_nextarg
4028 ld hl,b_0x1D80_start
4034 ld hl,b_0x1DA1_start
4236 call sub_1e12h ;1e97 get displacement
4283 call skip_to_nextarg
4302 call skip_to_nextarg
4391 ld hl,b_0x1F9B_start
4441 ld hl,b_0x2011_start
4516 ld hl,b_0x2200_start
4546 ld hl,b_0x218B_start
4550 ld hl,b_0x20ED_start
4554 ld hl,b_0x2108_start
4558 ld hl,b_0x21D2_start
4625 b_0x20ED_start: ; 1 byte opcodes (no parameters)
4654 b_0x2108_start: ; 1 byte opcodes
4655 defb 0c0h ;2108 ld r,r
4660 defb 0f8h ;210d add a,r
4665 defb 0f8h ;2112 adc a,r
4701 defb 0c0h ;2136 ret cc
4715 defb 0cfh ;2144 pop rr
4720 defb 0cfh ;2149 push rr
4725 defb 0ffh ;214e ex (sp),hl
4730 defb 0ffh ;2153 jp (hl)
4735 defb 0ffh ;2158 ex de,hl
4740 defb 0ffh ;215d ld sp,hl
4745 defb 0cfh ;2162 inc rr
4750 defb 0cfh ;2167 dec rr
4755 defb 0c7h ;216c inc r
4760 defb 0c7h ;2171 dec r
4765 defb 0ffh ;2176 ex af,af'
4770 defb 0cfh ;217b add hl,rr
4775 defb 0efh ;2180 ld (rr),a ;rr=bc,de
4780 defb 0efh ;2185 ld a,(rr) ;rr=bc,de
4787 b_0x218B_start: ; 2 byte opdodes
4788 defb 0c7h ;218b ld r,nn
4793 defb 0ffh ;2190 add a,nn
4798 defb 0ffh ;2195 adc a,nn
4803 defb 0ffh ;219a sub a,nn
4813 defb 0ffh ;21a4 and a,nn
4828 defb 0ffh ;21b3 cp a,nn
4833 defb 0ffh ;21b8 djnz
4843 defb 0e7h ;21c2 jr,cc
4849 defb 0d3h ;21c8 out (nn),a
4853 defb 0ffh ;21cc in a,(nn)
4860 b_0x21D2_start: ; 3 byte opcodes
4908 b_0x2200_start: ; prefix ED + 1 byte opcode
4911 defb 045h ;2202 retn
4913 defb 04dh ;2204 reti
4935 defb 0b0h ;221a ldir
4943 defb 0b8h ;2222 lddr
4951 defb 08bh ;222a otdm
4953 defb 09bh ;222c otdmr
4955 defb 083h ;222e otim
4957 defb 093h ;2230 otimr
4964 defb 0e7h ;2235 in r,(c) ;r=bcde
4969 defb 0f7h ;223a in r,(c) ;r=hl
4974 defb 0ffh ;223f in r,(c) ;r=a
4989 defb 0ffh ;224e out (c),r ;r=a
4994 defb 0cfh ;2253 sbc hl,rr
4999 defb 0cfh ;2258 adc hl,rr
5004 defb 0ffh ;225d im 0
5009 defb 0ffh ;2262 im 1
5014 defb 0ffh ;2267 im 2
5019 defb 0ffh ;226c ld i,a
5039 defb 0cfh ;2280 mlt rr
5044 defb 0c7h ;2285 tst r
5257 ld hl,b_0x2333_start
5274 ld hl,b_0x2354_start
5282 ld hl,b_0x1D80_start
5400 ld hl,b_0x2449_start
5512 ld hl,b_0x2538_start
5516 ld hl,b_0x253B_start
5763 ld hl,b_0x2717_start
5998 call get_lastarg_def
6128 ;------------------------------------------
6130 ;------------------------------------------
6137 ; The following 2 params are changeable by user.
6138 ; Should these moved to top ram?
6140 ddtrst: rst DRSTNUM ;rst used by ddtz
6141 ddtei: ei ;ints enabled/disabled while ddtz is running
6238 ;------------------------------------------
6240 .phase sysram_start+stacksize
6242 $stcka equ $ - stacksize
6250 reg.l2: db 0 ; 0fe50h
6251 reg.h2: db 0 ; 0fe51h
6252 reg.e2: db 0 ; 0fe52h
6253 reg.d2: db 0 ; 0fe53h
6254 reg.c2: db 0 ; 0fe54h
6255 reg.b2: db 0 ; 0fe55h
6256 reg.f2: db 0 ; 0fe56h
6257 reg.a2: db 0 ; 0fe57h
6259 reg.i: db high ivtab
6260 reg.iy: dw 0 ; 0fe5ah
6261 reg.ix: dw 0 ; 0fe5ch
6262 reg.e: db 0 ; 0fe5eh
6263 reg.d: db 0 ; 0fe5fh
6264 reg.c: db 0 ; 0fe60h
6265 reg.b: db 0 ; 0fe61h
6267 udcntl: db CWAITIO ; 0fe62h (mem-, io- wait)
6268 uromen: db ROM_DIS ; 0fe63h
6272 ucbar: db USR$CBAR ; 0fe65h
6277 reg.f: db 0 ; 0fe66h
6278 reg.a: db 0 ; 0fe67h
6279 reg.l: db 0 ; 0fe68h
6280 reg.h: db 0 ; 0fe69h
6281 reg.sp: dw TOPRAM ; 0fe6ah
6285 out (000h),a ;064c fe6c
6301 db 0C3h ;jp TPA ;065f feff ($+1): reg.pc
6306 ld (reg.l),hl ;0662 fe82: bpent:
6314 ;;; TODO: cbar on trap?
6330 ld a,CWAITROM+CWAITIO
6342 out (000h),a ;0692 feb2