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
3280 ld a,b ;1a28 ld r,nn
3326 ld (iy+000h),a ;1a83 dd/fd
3328 ld (iy+002h),c ;1a8a displacement
3329 ld (iy+003h),l ;1a8d nn
3489 call skip_to_nextarg
3571 call skip_to_nextarg
3597 ld hl,b_0x1C97_start
3605 call skip_to_nextarg
3634 call skip_to_nextarg
3733 ld hl,b_0x1D80_start
3739 ld hl,b_0x1DA1_start
3941 call sub_1e12h ;1e97 get displacement
3988 call skip_to_nextarg
4007 call skip_to_nextarg
4096 ld hl,b_0x1F9B_start
4146 ld hl,b_0x2011_start
4221 ld hl,b_0x2200_start
4251 ld hl,b_0x218B_start
4255 ld hl,b_0x20ED_start
4259 ld hl,b_0x2108_start
4263 ld hl,b_0x21D2_start
4330 b_0x20ED_start: ; 1 byte opcodes (no parameters)
4359 b_0x2108_start: ; 1 byte opcodes
4360 defb 0c0h ;2108 ld r,r
4365 defb 0f8h ;210d add a,r
4370 defb 0f8h ;2112 adc a,r
4406 defb 0c0h ;2136 ret cc
4420 defb 0cfh ;2144 pop rr
4425 defb 0cfh ;2149 push rr
4430 defb 0ffh ;214e ex (sp),hl
4435 defb 0ffh ;2153 jp (hl)
4440 defb 0ffh ;2158 ex de,hl
4445 defb 0ffh ;215d ld sp,hl
4450 defb 0cfh ;2162 inc rr
4455 defb 0cfh ;2167 dec rr
4461 defb 0c7h ;216c inc r
4466 defb 0c7h ;2171 dec r
4471 defb 0ffh ;2176 ex af,af'
4476 defb 0cfh ;217b add hl,rr
4481 defb 0efh ;2180 ld (rr),a ;rr=bc,de
4486 defb 0efh ;2185 ld a,(rr) ;rr=bc,de
4493 b_0x218B_start: ; 2 byte opdodes
4494 defb 0c7h ;218b ld r,nn
4499 defb 0ffh ;2190 add a,nn
4504 defb 0ffh ;2195 adc a,nn
4509 defb 0ffh ;219a sub a,nn
4519 defb 0ffh ;21a4 and a,nn
4534 defb 0ffh ;21b3 cp a,nn
4539 defb 0ffh ;21b8 djnz
4549 defb 0e7h ;21c2 jr,cc
4555 defb 0d3h ;21c8 out (nn),a
4559 defb 0ffh ;21cc in a,(nn)
4566 b_0x21D2_start: ; 3 byte opcodes
4614 b_0x2200_start: ; prefix ED + 1 byte opcode
4617 defb 045h ;2202 retn
4619 defb 04dh ;2204 reti
4641 defb 0b0h ;221a ldir
4649 defb 0b8h ;2222 lddr
4657 defb 08bh ;222a otdm
4659 defb 09bh ;222c otdmr
4661 defb 083h ;222e otim
4663 defb 093h ;2230 otimr
4670 defb 0e7h ;2235 in r,(c) ;r=bcde
4675 defb 0f7h ;223a in r,(c) ;r=hl
4680 defb 0ffh ;223f in r,(c) ;r=a
4695 defb 0ffh ;224e out (c),r ;r=a
4700 defb 0cfh ;2253 sbc hl,rr
4705 defb 0cfh ;2258 adc hl,rr
4710 defb 0ffh ;225d im 0
4715 defb 0ffh ;2262 im 1
4720 defb 0ffh ;2267 im 2
4725 defb 0ffh ;226c ld i,a
4745 defb 0cfh ;2280 mlt rr
4750 defb 0c7h ;2285 tst r
4939 ld hl,b_0x2333_start
4956 ld hl,b_0x2354_start
4964 ld hl,b_0x1D80_start
5082 ld hl,b_0x2449_start
5194 ld hl,b_0x2538_start
5198 ld hl,b_0x253B_start
5445 ld hl,b_0x2717_start
5680 call get_lastarg_def
5810 ;------------------------------------------
5812 ;------------------------------------------
5819 ; The following 2 params are changeable by user.
5820 ; Should these moved to top ram?
5823 rst DDTZRSTVEC ;rst used by ddtz
5824 ddtei: ei ;ints enabled/disabled while ddtz is running
5921 ;------------------------------------------
5923 .phase sysram_start+bs$stack$size
5925 $stcka equ $ - bs$stack$size
5933 reg.l2: db 0 ; 0fe50h
5934 reg.h2: db 0 ; 0fe51h
5935 reg.e2: db 0 ; 0fe52h
5936 reg.d2: db 0 ; 0fe53h
5937 reg.c2: db 0 ; 0fe54h
5938 reg.b2: db 0 ; 0fe55h
5939 reg.f2: db 0 ; 0fe56h
5940 reg.a2: db 0 ; 0fe57h
5942 reg.i: db high ivtab
5943 reg.iy: dw 0 ; 0fe5ah
5944 reg.ix: dw 0 ; 0fe5ch
5945 reg.e: db 0 ; 0fe5eh
5946 reg.d: db 0 ; 0fe5fh
5947 reg.c: db 0 ; 0fe60h
5948 reg.b: db 0 ; 0fe61h
5950 udcntl: db CWAITIO ; 0fe62h (mem-, io- wait)
5951 uromen: db ROM_DIS ; 0fe63h
5955 ucbar: db USR$CBAR ; 0fe65h
5960 reg.f: db 0 ; 0fe66h
5961 reg.a: db 0 ; 0fe67h
5962 reg.l: db 0 ; 0fe68h
5963 reg.h: db 0 ; 0fe69h
5964 reg.sp: dw TOPRAM ; 0fe6ah
5968 out (000h),a ;064c fe6c
5984 db 0C3h ;jp TPA ;065f feff ($+1): reg.pc
5989 ld (reg.l),hl ;0662 fe82: bpent:
5997 ;;; TODO: cbar on trap?
6013 ld a,CWAITROM+CWAITIO
6025 out (000h),a ;0692 feb2