; - Cut the .PRL header (first 256 byte) end rename the result to DDTZ.COM.\r
\r
;-------------------------------------------------------------------------------\r
-; Relocation loader\r
-;\r
-TPA equ 0100h\r
- cseg\r
- .phase TPA\r
-\r
- jp start\r
- ds 3\r
-\r
-ldr_end:\r
-ldr_size equ $ - TPA\r
-current_phase defl $\r
-\r
- .dephase\r
-current_cseg defl $\r
-\r
-;-------------------------------------------------------------------------------\r
-; DDT/Z core\r
-;\r
-\r
; Some greneral definitions\r
\r
-TAB equ 9\r
-LF equ 10\r
-CR equ 13\r
+TAB equ 09h\r
+CR equ 0dh\r
+LF equ 0ah\r
\r
; CP/M memory layout\r
\r
SYMCASE_LOWER equ 2 ;Convert to lower case if set, else to upper case\r
\r
;-------------------------------------------------------------------------------\r
+; Relocation loader\r
+;\r
+TPA equ 0100h\r
+ cseg\r
+ .phase TPA\r
+\r
+ jp start\r
+ ds 3\r
+\r
+ldr_end:\r
+ldr_size equ $ - TPA\r
+current_phase defl $\r
+\r
+ .dephase\r
+current_cseg defl $\r
+\r
+;-------------------------------------------------------------------------------\r
+; DDT/Z core\r
+;\r
+\r
\r
ddtz_base:\r
jp ddtz_bdos\r
l0003h:\r
- rst 30h\r
-sub_0004h:\r
+ rst 30h ;rst used by ddtz\r
+di_or_ei: ;ints enabled/disabled while ddtz is running\r
nop\r
ret\r
ddtz_bdos:\r
ld sp,stack\r
exx\r
ld de,ddtz_base\r
- or a\r
- sbc hl,de\r
- add hl,de\r
+ call cp_hl_de\r
jr c,l0079h\r
ex de,hl\r
l0079h:\r
ld a,0fbh\r
l0093h:\r
ld (reg.iff),a\r
- call sub_0004h\r
+ call di_or_ei\r
ld hl,ddtz_base\r
ld l,000h\r
ld (reg_sp),hl\r
dw cmd_Y ;examine [and substitute] Y variables\r
dw cmd_Z ;Zap (fill) memory with a byte string\r
\r
+ERROR:\r
+ ld hl,(error_func)\r
+exe_hl:\r
+ call CALL_HL\r
+ ;fall thru\r
mainloop:\r
ld sp,stack\r
ld hl,p_msg_error\r
call bp_clr_temporary\r
ld hl,(cmd_rpt)\r
ld de,mainloop\r
+ ld (cmd_rpt),de\r
call cp_hl_de\r
ld a,'>'\r
call outchar\r
call get_line\r
call skipbl\r
jr z,exe_hl\r
- ld hl,mainloop\r
- ld (cmd_rpt),hl\r
inc de\r
sub '@'\r
jr c,ERROR\r
cp 'Z'+1-'@'\r
jr nc,ERROR\r
- add a,a\r
ld hl,CMDTAB\r
- call add_hl_a\r
+ call add_hl_a2\r
ld a,(hl)\r
inc hl\r
ld h,(hl)\r
ld l,a\r
jr exe_hl\r
\r
-ERROR:\r
- ld hl,(error_func)\r
-exe_hl:\r
- call CALL_HL\r
- jr mainloop\r
-\r
;-------------------------------------------------------------------------------\r
\r
p_msg_error:\r
;fall thru\r
crlf:\r
call pstr_inl\r
- db CR,LF+80h\r
- call inchar\r
- ld a,0\r
+ dc CR,LF\r
+ xor a\r
ld (con_col),a\r
+ call inchar\r
jr c,mainloop\r
ret\r
\r
sub_01d9h:\r
call pstr_inl\r
dc '-'\r
- dec hl\r
- jp cpl.hl\r
+ jp neg.hl\r
\r
out_hl_dec_neg:\r
push hl\r
l01c9h:\r
rlca\r
push af\r
- ld a,'0'/2\r
- adc a,a\r
- call outchar\r
+ and 1\r
+ call out_dgt\r
pop af\r
djnz l01c9h\r
ld a,'"'\r
cp ' '\r
push af\r
call nc,outbl\r
- call outquote\r
+ call pstr_inl\r
+ dc ''''\r
pop af\r
jr nc,l0242h\r
sub 0c0h\r
call outchar\r
cp ''''\r
call z,outchar\r
- call outquote\r
+ call pstr_inl\r
+ dc ''''\r
sla c\r
pop bc\r
ret nc\r
call outbl\r
outbl:\r
ld a,' '\r
- jr outchar\r
-\r
-outquote:\r
- ld a,''''\r
outchar:\r
push ix\r
push iy\r
pop ix\r
ret\r
\r
-pstr:\r
- ld a,(hl)\r
- inc hl\r
- and a\r
- ret z\r
- call outchar\r
- and a\r
- ret m\r
- jr pstr\r
-\r
-pstr_inl:\r
- ex (sp),hl\r
- call pstr\r
- ex (sp),hl\r
- ret\r
-\r
p_align_@_sym:\r
push de\r
ld de,(var.@)\r
ld c,BDOS_CSTAT\r
call ddtz_bdos\r
and a\r
- jr z,l0284h\r
+ jr z,inch1\r
ld c,BDOS_CIN\r
call ddtz_bdos\r
scf\r
-l0284h:\r
+inch1:\r
pop bc\r
pop de\r
pop hl\r
or a\r
ret\r
\r
+;-------------------------------------------------------------------------------\r
+\r
next_arg:\r
call skipbl\r
cp ','\r
ret nz\r
- inc de\r
- call skipbl\r
+ call skipbl0\r
cp a\r
ret\r
\r
\r
;-------------------------------------------------------------------------------\r
\r
+add_hl_a2:\r
+ add a,a\r
add_hl_a:\r
add a,l\r
ld l,a\r
sub_hl_a:\r
push bc\r
ld c,a\r
- ld b,0\r
- or a\r
+ xor a\r
+ ld b,a\r
sbc hl,bc\r
pop bc\r
ret\r
sub_0318h:\r
push bc\r
res 7,b\r
- defb 03eh ;ld a,nn\r
+ defb 03eh ;ld a,nn: swallow push bc\r
sub_031ch:\r
push bc\r
push de\r
pop bc\r
ret\r
l0336h:\r
- call sub_0345h\r
+ call str_sel_next\r
l0339h:\r
pop de\r
and a\r
pop bc\r
ret\r
\r
-sel_dc_string:\r
+str_sel:\r
inc b\r
-l033eh:\r
- dec b\r
- ret z\r
- call sub_0345h\r
- jr l033eh\r
+ jr str_sel2\r
+str_sel1:\r
+ call str_sel_next\r
+str_sel2:\r
+ djnz str_sel1\r
+ ret\r
\r
-sub_0345h:\r
+str_sel_next:\r
ld a,(hl)\r
and a\r
ret z\r
ret m\r
jr l0348h\r
\r
-sub_034eh:\r
+get_arg_range_target:\r
call get_arg_range\r
push hl\r
push bc\r
call next_arg\r
- call sub_0363h\r
+ call get_arg_final\r
ex de,hl\r
pop bc\r
pop hl\r
jr c,error0\r
ret\r
\r
-sub_0363h:\r
+get_arg_final:\r
call sub_035dh\r
l0366h:\r
jp assert_eol\r
l0411h:\r
ld hl,tab_func_eqlege\r
ld a,b\r
- add a,a\r
- call add_hl_a\r
+ call add_hl_a2\r
ld c,(hl)\r
inc hl\r
ld b,(hl)\r
call lookupch\r
ld a,b\r
ld hl,tblf_opa\r
- add a,a\r
- call add_hl_a\r
+ call add_hl_a2\r
ld c,(hl)\r
inc hl\r
ld b,(hl)\r
ret nc\r
inc de\r
ld hl,(BDOS+1)\r
+ dec hl\r
cp 'T'\r
ret z\r
ld hl,(high_load)\r
jr c,error1\r
inc de\r
get_y_val:\r
- add a,a\r
ld hl,reg_Y\r
- call add_hl_a\r
+ call add_hl_a2\r
ld a,(hl)\r
inc hl\r
ld h,(hl)\r
inc hl\r
ld h,(hl)\r
ld l,a\r
- and a\r
+ xor a ;clr cy, a=0\r
bit 0,c\r
ret nz\r
- ld h,000h\r
+ ld h,a\r
ret\r
\r
+fact_factinv:\r
+ call fact_factor\r
+ jr cpl.hl\r
+\r
fact_factneg:\r
call fact_factor\r
+neg.hl:\r
dec hl\r
cpl.hl:\r
ld a,h\r
ld l,a\r
ret\r
\r
-fact_factinv:\r
- call fact_factor\r
- jr cpl.hl\r
-\r
fact_mem:\r
call expr1\r
jr c,error1\r
call p_flags\r
ld a,(reg.iff)\r
cp 0f3h\r
- jp z,outbl\r
+ jr z,outbl_1\r
ld a,'E'\r
jp outchar\r
p_f2:\r
ld a,(reg.f2)\r
call p_flags\r
- jp outbl\r
+ jr outbl_1\r
\r
p_flags:\r
push hl\r
ld a,(de)\r
call out_hex\r
l06e2h:\r
- call outbl\r
pop de\r
pop hl\r
- ret\r
+outbl_1:\r
+ jp outbl\r
\r
b_06e9_start:\r
DC 'A '\r
cmd_G:\r
sub a\r
ld (trace_call_flag),a\r
- ld (l0941h),a\r
+ ld (bp_p_cpu_flag),a\r
call expr\r
jr c,l0740h\r
ld (reg.pc),hl\r
l0740h:\r
call skipbl\r
- jp z,user_go\r
+ jr z,user_go0\r
cp ';'\r
jp nz,ERROR\r
inc de\r
ld a,002h\r
call bp_enter\r
+user_go0:\r
jp user_go\r
\r
;-------------------------------------------------------------------------------\r
ld de,expr_bufe\r
call cp_hl_de\r
jr nc,error12\r
- pop hl\r
- ld (expr_p2),hl\r
- pop de\r
- ex de,hl\r
+ pop de\r
+ pop hl\r
+ push de\r
ldir\r
- xor a\r
- ld (de),a\r
- inc de\r
ex de,hl\r
+ ld (hl),c ; trailing 0\r
+ inc hl\r
ld (expr_p1),hl\r
- ld hl,(expr_p2)\r
+ pop hl\r
ret\r
\r
;-------------------------------------------------------------------------------\r
+; Breakpoint handling routine.\r
\r
bpddtz:\r
ld (reg.l),hl\r
push ix\r
push iy\r
ld a,i\r
- call sub_0004h\r
+ call di_or_ei\r
ld h,a\r
ld l,000h\r
push hl\r
- ld a,0f3h\r
+ ld a,0f3h ; EI\r
jp po,l08dfh\r
- ld a,0fbh\r
+ ld a,0fbh ; DI\r
l08dfh:\r
ld (reg.iff),a\r
ex af,af'\r
push bc\r
push de\r
push hl\r
- call sub_097ah\r
+ call bp_restore_mem\r
ld a,(b_21e2_start)\r
dec a\r
jr z,l090bh\r
- call inchar\r
- jr c,l0902h\r
+ call inchar ;Keyboard hit?\r
+ jr c,do_break ;yes\r
call sub_0913h\r
and a\r
jp z,user_go\r
and 083h\r
jp z,l2151h\r
-l0902h:\r
+do_break:\r
call bp_clr_temporary\r
call p_cpustat\r
jp mainloop\r
ld a,080h\r
ex af,af'\r
sub a\r
- ld (l0941h),a\r
+ ld (bp_p_cpu_flag),a\r
call bpl_init\r
\r
ld a,(ix+000h)\r
bit 4,(ix+000h)\r
ret z\r
ld a,001h\r
- ld (l0941h),a\r
+ ld (bp_p_cpu_flag),a\r
ret\r
l0974h:\r
ex af,af'\r
ex af,af'\r
ret\r
\r
-sub_097ah:\r
+bp_restore_mem:\r
call bpl_init\r
\r
bit 5,(ix+000h)\r
call bpl_next\r
ret\r
\r
-sub_09a6h:\r
+bp_tst_@pc:\r
call bpl_init\r
\r
ld a,(ix+000h)\r
- and 003h\r
- jr z,l09c0h\r
+ and 003h ;User bp (temporary or permanent)?\r
+ jr z,bp_tst_e ;No, check next\r
ld e,(ix+002h)\r
ld d,(ix+003h)\r
ld hl,(reg.pc)\r
- call cp_hl_de\r
- ret z\r
-l09c0h:\r
-\r
+ call cp_hl_de ;Current PC is on a User bp\r
+ ret z ;Return zero\r
+bp_tst_e:\r
call bpl_next\r
sub a\r
- inc a\r
- ret\r
+ inc a ;Not on a user bp\r
+ ret ;Return not zero\r
\r
-sub_09cah:\r
+bp_trace_enter:\r
call bp_get_freeslot\r
ld (ix+004h),001h\r
ld (ix+005h),000h\r
ld a,(b_21e2_start)\r
and a\r
ld a,008h\r
- jr nz,l09edh\r
+ jr nz,bp_t_e\r
rra\r
-l09edh:\r
+bp_t_e:\r
ld (ix+000h),a\r
ret\r
\r
inc hl\r
ld (hl),d\r
l0a1dh:\r
-\r
call bpl_next\r
ret\r
\r
user_go:\r
sub a\r
ld (b_21e2_start),a\r
- ld a,(l0941h)\r
+ ld a,(bp_p_cpu_flag)\r
and a\r
call nz,p_cpustat\r
- call sub_09a6h\r
+ call bp_tst_@pc\r
ld c,007h\r
jr nz,l0a41h\r
ld a,001h\r
ld (b_21e2_start),a\r
- call sub_1ffeh\r
+ call tc_set_bp\r
ld c,008h\r
l0a41h:\r
call bp_set_to_mem\r
bp_clr_condition:\r
ld a,(ix+000h)\r
and 003h\r
- ret nz\r
+ ret nz ; No (user) bp set\r
ld e,(ix+006h)\r
ld d,(ix+007h)\r
ld a,d\r
or e\r
- ret z\r
+ ret z ; No conditional expression\r
push bc\r
ld h,d\r
ld l,e\r
add hl,bc\r
ex de,hl\r
ld c,003h\r
- jp l0c33h\r
+ jr l0c33h\r
\r
;-------------------------------------------------------------------------------\r
; > X\r
jp nc,p_cpustat0\r
call assert_eol\r
ld a,b\r
- cp 01eh\r
+ cp 30\r
jr z,l0c5fh\r
- cp 01fh\r
+ cp 31\r
jr z,l0c4fh\r
- cp 01dh\r
+ cp 29\r
jp z,ERROR\r
ex de,hl\r
ld hl,t_reg_names\r
- call sel_dc_string\r
+ call str_sel\r
l0c12h:\r
call l0c33h\r
l0c15h:\r
call get_line\r
call skipbl\r
jr z,l0c30h\r
- call sub_0363h\r
+ call get_arg_final\r
ex de,hl\r
pop bc\r
pop hl\r
ret\r
\r
t_reg_names:\r
- DC 'BC'''\r
- DC 'DE'''\r
- DC 'HL'''\r
- DC 'BC'\r
- DC 'DE'\r
- DC 'HL'\r
- DC 'A'''\r
- DC 'B'''\r
- DC 'C'''\r
- DC 'D'''\r
- DC 'E'''\r
- DC 'H'''\r
- DC 'L'''\r
- DC 'A'\r
- DC 'B'\r
- DC 'C'\r
- DC 'D'\r
- DC 'E'\r
- DC 'H'\r
- DC 'L'\r
- DC 'IX'\r
- DC 'IY'\r
- DC 'SP'\r
- DC 'PC'\r
- DC 'X'\r
- DC 'Y'\r
- DC 'S'\r
- DC 'P'\r
- DC 'I'\r
- DC 'IP'\r
- DC 'F'''\r
- DC 'F'\r
+ DC 'BC''' ;0\r
+ DC 'DE''' ;1\r
+ DC 'HL''' ;2\r
+ DC 'BC' ;3\r
+ DC 'DE' ;4\r
+ DC 'HL' ;5\r
+ DC 'A''' ;6\r
+ DC 'B''' ;7\r
+ DC 'C''' ;8\r
+ DC 'D''' ;9\r
+ DC 'E''' ;10\r
+ DC 'H''' ;11\r
+ DC 'L''' ;12\r
+ DC 'A' ;13\r
+ DC 'B' ;14\r
+ DC 'C' ;15\r
+ DC 'D' ;16\r
+ DC 'E' ;17\r
+ DC 'H' ;18\r
+ DC 'L' ;19\r
+ DC 'IX' ;20\r
+ DC 'IY' ;21\r
+ DC 'SP' ;22\r
+ DC 'PC' ;23\r
+ DC 'X' ;24\r
+ DC 'Y' ;25\r
+ DC 'S' ;26\r
+ DC 'P' ;27\r
+ DC 'I' ;28\r
+ DC 'IP' ;29\r
+ DC 'F''' ;30\r
+ DC 'F' ;31\r
DB 0\r
\r
b_0cfa_start:\r
; Input a byte from port\r
\r
cmd_I:\r
- ld hl,cmd_I\r
ld (cmd_rpt),hl\r
ld hl,(last_I)\r
call get_lastarg_def\r
; Output a byte to a port\r
\r
cmd_O:\r
- ld hl,cmd_O\r
ld (cmd_rpt),hl\r
ld hl,(last_O_val)\r
call get_arg_def\r
; Verify (compare) two memory areas\r
\r
cmd_V:\r
- call sub_034eh\r
+ call get_arg_range_target\r
l0dedh:\r
push bc\r
ld a,(de)\r
call crlf\r
l0e10h:\r
pop bc\r
- inc hl\r
inc de\r
- dec bc\r
- ld a,b\r
- or c\r
- jr nz,l0dedh\r
+ cpi\r
+ jp pe,l0dedh\r
ret\r
\r
;-------------------------------------------------------------------------------\r
inc de\r
l0e1fh:\r
push af\r
- call sub_034eh\r
+ call get_arg_range_target\r
push hl\r
push de\r
push bc\r
add hl,bc\r
l0ea7h:\r
ld bc,16\r
- and a\r
+ and a ;clear carry\r
call sub_0f58h\r
pop hl\r
pop bc\r
ret nz\r
jp ERROR\r
\r
-sub_0ef7h:\r
+sub_0ef7h: ;from cmd_Q, cmd_Z\r
db 0e6h ; and 037h (clear carry)\r
-sub_0ef8h:\r
+sub_0ef8h: ;from cmd_S\r
scf\r
l0ef9h:\r
push af\r
; Display memory in hex and ASCII\r
\r
cmd_D:\r
- ld hl,cmd_D\r
ld (cmd_rpt),hl\r
ld hl,(last_D)\r
ld bc,128\r
call pstr_inl\r
DC ' Top = '\r
ld hl,(BDOS+1)\r
+ dec hl\r
call out_hl\r
jp crlf\r
\r
l1395h:\r
call assert_eol\r
ld a,(prefix_ixiy)\r
-l139bh:\r
+as_store_4:\r
ld (iy+000h),a\r
ld (iy+001h),b\r
ld (iy+002h),l\r
inc de\r
ld b,032h\r
\r
-as.store_3:\r
+as_store_3:\r
call assert_eol\r
ld (iy+000h),b\r
ld (iy+001h),l\r
l13c9h:\r
call assert_eol\r
ld a,0edh\r
- jr l139bh\r
+ jr as_store_4\r
l13d0h:\r
ld b,022h\r
- jr as.store_3\r
+ jr as_store_3\r
\r
l13d4h:\r
ld b,a\r
add a,006h\r
l143fh:\r
ld b,a\r
-as.store_2:\r
+as_store_2:\r
call assert_eol\r
ld (iy+000h),b\r
ld (iy+001h),l\r
call test_expr\r
call test_paren_close\r
ld b,03ah\r
- jp as.store_3\r
+ jp as_store_3\r
\r
l1471h:\r
call assert_comma\r
\r
l14e3h:\r
ld b,02ah\r
- jp as.store_3\r
+ jp as_store_3\r
\r
l14e8h:\r
call test_expr\r
ld a,001h\r
add a,b\r
ld b,a\r
- jp as.store_3\r
+ jp as_store_3\r
l14f5h:\r
call assert_comma\r
call get_char_upper\r
l163eh:\r
pop af\r
call test_expr\r
- jp as.store_3\r
+ jp as_store_3\r
\r
as.RET:\r
call arg.cc_ZCPS\r
pop af\r
l166eh:\r
call test_expr\r
- jp as.store_3\r
+ jp as_store_3\r
l1674h:\r
call assert_eol\r
ld a,b\r
ld b,0fdh\r
l1687h:\r
ld l,0e9h\r
- jp as.store_2\r
+ jp as_store_2\r
\r
l168ch:\r
DC '(HL)'\r
call assert_comma\r
l16aeh:\r
call arg.j_displ\r
- jp as.store_2\r
+ jp as_store_2\r
\r
as.IM:\r
call arg.imm_8bit\r
jr c,l1715h\r
call arg.addr_8bit\r
ld b,0dbh\r
- jp as.store_2\r
+ jp as_store_2\r
l170fh:\r
call assert_comma\r
call sub_171bh\r
jr nz,error7\r
inc de\r
ld b,0d3h\r
- jp as.store_2\r
+ jp as_store_2\r
\r
as.EX:\r
ld hl,b_176d_start\r
\r
arg.zz:\r
push hl\r
- ld hl,t_BC.DE.HL.AF\r
+ ld hl,t_arg_rp2\r
jr l181fh\r
\r
arg.reg_16bit:\r
\r
arg.ww:\r
push hl\r
- ld hl,t_BC.DE.HL.SP\r
+ ld hl,t_arg_rp\r
l181fh:\r
push bc\r
call sub_030ah\r
call skipbl\r
push bc\r
push hl\r
- ld hl,t_BCDEHL_HL_A\r
+ ld hl,t_arg_r\r
call sub_030ah\r
ld a,b\r
pop hl\r
jr l18b1h\r
\r
arg.cc_ZC:\r
- ld hl,t_tstfl_ZC\r
+ ld hl,t_arg_cc\r
ld c,003h\r
l18b1h:\r
push bc\r
; List disassembled code\r
\r
cmd_L:\r
- ld hl,cmd_L\r
ld (cmd_rpt),hl\r
call expr\r
jr nc,l18dbh\r
ld a,(con_col)\r
add a,5\r
ld c,a\r
- call pstr\r
+ call pstr ;print mnemonic\r
call p_goto_col\r
ex de,hl\r
- call call_hl\r
+ call call_hl ;print arguments\r
pop bc\r
ld a,(disas_argtype)\r
ld hl,(disas_arg_16)\r
\r
;-------------------------------------------------------------------------------\r
\r
+disas_nopfx:\r
+ ld hl,b_1b54_start ;2 byte opcodes\r
+ call lookup_op\r
+ ld b,2\r
+ ret c\r
+ ld hl,b_1ab6_start ;1 byte opcodes (no parameters)\r
+ call sub_1a72h\r
+ ld b,1\r
+ ret c\r
+ ld hl,b_1ad1_start ;1 byte opcodes\r
+ call lookup_op\r
+ ld b,1\r
+ ret c\r
+ ld hl,b_1b9b_start ;3 byte opcodes\r
+ call lookup_op\r
+ ret nc\r
+ ld b,3\r
+ ret\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
+disas_pfx.ED:\r
+ inc iy\r
+ ld hl,b_1bc9_start ;1 byte opcode, no arguments\r
+ call sub_1a72h\r
+ ld b,2\r
+ ret c\r
+ ld hl,b_1bf4_start\r
+ call lookup_op\r
+ ld b,2\r
+ ret c\r
+\r
+ ld hl,l228bh\r
+ call lookup_op\r
+ ld b,3\r
+ ret c\r
+ ld hl,b_1c40_start\r
+ call lookup_op\r
+ ld b,4\r
+ ret\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
+disas_pfx.CB:\r
+ push iy\r
+ inc iy\r
+ ld a,(isprefix_ixiy)\r
+ and a\r
+ jr z,l1a42h\r
+ inc iy\r
+l1a42h:\r
+ ld hl,b_1c55_start\r
+ call lookup_op\r
+ pop iy\r
+ ld b,2\r
+ ret\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
disas_pfx.DDFD:\r
inc iy\r
ld hl,b_19ef_start\r
\r
;-------------------------------------------------------------------------------\r
\r
-disas_pfx.ED:\r
- inc iy\r
- ld hl,b_1bc9_start\r
- call sub_1a72h\r
- ld b,2\r
- ret c\r
- ld hl,b_1bf4_start\r
- call lookup_opc\r
- ld b,2\r
- ret c\r
-\r
- ld hl,l228bh\r
- call lookup_opc\r
- ld b,3\r
- ret c\r
- ld hl,b_1c40_start\r
- call lookup_opc\r
- ld b,4\r
- ret\r
-\r
-;-------------------------------------------------------------------------------\r
-\r
-disas_pfx.CB:\r
- push iy\r
- inc iy\r
- ld a,(isprefix_ixiy)\r
- and a\r
- jr z,l1a42h\r
- inc iy\r
-l1a42h:\r
- ld hl,b_1c55_start\r
- call lookup_opc\r
- pop iy\r
- ld b,2\r
- ret\r
-\r
-;-------------------------------------------------------------------------------\r
-\r
-disas_nopfx:\r
- ld hl,b_1b54_start\r
- call lookup_opc\r
- ld b,2\r
- ret c\r
- ld hl,b_1ab6_start\r
- call sub_1a72h\r
- ld b,1\r
- ret c\r
- ld hl,b_1ad1_start\r
- call lookup_opc\r
- ld b,1\r
- ret c\r
- ld hl,b_1b9b_start\r
- call lookup_opc\r
- ret nc\r
- ld b,3\r
- ret\r
-\r
-;-------------------------------------------------------------------------------\r
-\r
sub_1a72h:\r
ld a,(hl)\r
cp 0ffh\r
scf\r
ret\r
\r
-lookup_opc:\r
+lookup_op:\r
ld a,(iy+000h)\r
and (hl)\r
inc hl\r
inc hl\r
ld a,(hl)\r
and a\r
- jr nz,lookup_opc\r
+ jr nz,lookup_op\r
ret\r
\r
l1aa8h:\r
dw l1ce5h\r
db 0\r
\r
-; 2 byte opdodes\r
+; 2 byte opcodes\r
b_1b54_start:\r
db 0c7h,006h,056h ;ld r,nn\r
dw l1cfah\r
jp p_arg_nn_rp\r
\r
p_arg_r1:\r
- ld hl,t_BCDEHL_HL_A\r
+ ld hl,t_arg_r\r
jr p_arg\r
\r
b_1e78_start:\r
ld hl,t_HL.IX.IY\r
jr p_arg\r
p_arg_zz:\r
- ld hl,t_BC.DE.HL.AF\r
+ ld hl,t_arg_rp2\r
jr l1e8eh\r
p_arg_ww:\r
- ld hl,t_BC.DE.HL.SP\r
+ ld hl,t_arg_rp\r
l1e8eh:\r
ld a,(iy+000h)\r
rra\r
ld hl,t_tstfl_ZCPS\r
p_arg:\r
ld b,a\r
- call sel_dc_string\r
- jp pstr\r
+ ;fall thru\r
+pstr_sel:\r
+ call str_sel\r
+ ;fall thru\r
+pstr:\r
+ ld a,(hl)\r
+ inc hl\r
+ and a\r
+ ret z\r
+ call outchar\r
+ ret m\r
+ jr pstr\r
+\r
+pstr_inl:\r
+ ex (sp),hl\r
+ call pstr\r
+ ex (sp),hl\r
+ ret\r
\r
;-------------------------------------------------------------------------------\r
\r
DC 'TSTIO'\r
DB 0\r
\r
-t_BCDEHL_HL_A:\r
+t_arg_r:\r
DC 'B'\r
DC 'C'\r
DC 'D'\r
DC '(HL)'\r
DC 'A'\r
DB 0\r
-t_BC.DE.HL.SP:\r
+t_arg_rp:\r
DC 'BC'\r
DC 'DE'\r
DC 'HL'\r
DC 'SP'\r
DB 0\r
-t_BC.DE.HL.AF:\r
+t_arg_rp2:\r
DC 'BC'\r
DC 'DE'\r
t_HL.AF:\r
DC 'IX'\r
DC 'IY'\r
DB 0\r
-t_tstfl_ZC:\r
+t_arg_cc:\r
DC 'NZ'\r
DC 'Z'\r
DC 'NC'\r
\r
;-------------------------------------------------------------------------------\r
\r
-sub_1ffeh:\r
+tc_set_bp:\r
ld hl,(reg.pc)\r
ld a,h\r
or l\r
ld de,BDOS\r
and a\r
sbc hl,de\r
- ld hl,l20edh\r
+ ld hl,l20edh ;set break after BDOS call\r
jr z,l2031h\r
ld iy,(reg.pc)\r
call disas_get_instrlen\r
ld b,0\r
ld hl,(reg.pc)\r
add hl,bc\r
- call sub_09cah\r
+ call bp_trace_enter\r
ld iy,(reg.pc)\r
ld hl,b_2039_start\r
- call lookup_opc\r
+ call lookup_op\r
ccf\r
ret c\r
ex de,hl\r
l2031h:\r
call CALL_HL\r
- call c,sub_09cah\r
+ call c,bp_trace_enter\r
l2037h:\r
scf\r
ret\r
dw l20dch\r
db 0ffh,0cfh,000h ;rst 8\r
dw l2115h\r
- db 0c7h,0c7h,000h ;\r
+ db 0c7h,0c7h,000h ;rst n\r
dw l20f9h\r
- db 0c7h,0c4h,000h ;\r
+ db 0c7h,0c4h,000h ;call cc,mn\r
dw l2080h\r
- db 0f7h,010h,000h ;\r
+ db 0f7h,010h,000h ;djnz d; jr d\r
dw l2093h\r
- db 0e7h,020h,000h ;\r
+ db 0e7h,020h,000h ;jr cc,d\r
dw l2093h\r
- db 0c7h,0c2h,000h ;\r
+ db 0c7h,0c2h,000h ;jp cc,mn\r
dw l208bh\r
- db 0c7h,0c0h,000h ;\r
+ db 0c7h,0c0h,000h ;ret cc\r
dw l20c5h\r
db 0\r
\r
;-------------------------------------------------------------------------------\r
-\r
+; call mn call cc,mn\r
l2080h:\r
ld a,(b_21e2_start)\r
and a\r
ld a,(trace_call_flag)\r
and a\r
ret nz\r
+\r
+; jp mn jp cc,mn\r
l208bh:\r
ld l,(iy+001h)\r
ld h,(iy+002h)\r
scf\r
ret\r
+\r
+;jr, djnz\r
l2093h:\r
ld c,(iy+001h)\r
ld a,c\r
inc hl\r
scf\r
ret\r
+\r
+; jp (hl)\r
l20a2h:\r
ld hl,(reg.l)\r
scf\r
ret\r
+\r
+; Prefix DD\r
l20a7h:\r
ld hl,(reg.ix)\r
jr l20afh\r
+; Prefix FD\r
l20ach:\r
ld hl,(reg.iy)\r
l20afh:\r
ld a,(iy+001h)\r
- cp 0e9h\r
+ cp 0e9h ; jp (ix); jp (iy)\r
scf\r
ret z\r
and a\r
ret\r
+\r
+; Prefix ED\r
l20b8h:\r
ld a,(iy+001h)\r
- cp 04dh\r
+ cp 04dh ; reti\r
jr z,l20dch\r
- cp 045h\r
+ cp 045h ; retn\r
jr z,l20dch\r
and a\r
ret\r
+\r
+;ret cc\r
l20c5h:\r
ld a,(iy+000h)\r
ld (l20d7h),a\r
inc hl\r
jp (hl)\r
\r
+;ret\r
l20dch:\r
ld a,(b_21e2_start)\r
and a\r
pop hl\r
ret\r
l20edh:\r
- ld hl,(reg_sp)\r
+ ld hl,(reg_sp) ;break on return address\r
ld e,(hl)\r
inc hl\r
ld d,(hl)\r
ex de,hl\r
- call sub_09cah\r
+ call bp_trace_enter\r
+;rst 8\r
+l2115h:\r
and a\r
ret\r
\r
+;rst n\r
l20f9h:\r
ld a,(l0003h)\r
cp (iy+000h)\r
l2113h:\r
scf\r
ret\r
-l2115h:\r
- and a\r
- ret\r
\r
;-------------------------------------------------------------------------------\r
; >>C[N][J] [steps]\r
; trace over Calls [No list] [Jumps only] /.While./.Until.\r
\r
cmd_C:\r
- ld hl,cmd_C\r
ld a,1\r
- jr l2122h\r
+ jr cmd_tc\r
\r
;-------------------------------------------------------------------------------\r
; >>T[N][J] [steps]\r
\r
cmd_T:\r
xor a\r
- ld hl,cmd_T\r
-l2122h:\r
+cmd_tc:\r
ld (cmd_rpt),hl\r
ld (trace_call_flag),a\r
call get_char_upper\r
sub 'N'\r
- jr nz,l212eh\r
+ jr nz,tc_non\r
inc de\r
-l212eh:\r
+tc_non:\r
ld (trace_N_flag),a\r
call get_char_upper\r
sub 'J'\r
- jr nz,l2137h\r
+ jr nz,tc_noj\r
inc de\r
-l2137h:\r
+tc_noj:\r
ld (trace_J_flag),a\r
- call sub_21a6h\r
- jr z,l2145h\r
- ld hl,1\r
+ call tc_chk_u_or_w\r
+ jr z,tc_save_uw_expr_ptr\r
+ ld hl,1 ;default: 1 step\r
call get_lastarg_def\r
-l2145h:\r
- ld (trace_count),hl\r
+tc_save_uw_expr_ptr:\r
+ ld (trace_cnt_or_ptr),hl\r
sub a\r
- ld (l0941h),a\r
+ ld (bp_p_cpu_flag),a\r
l214ch:\r
- call sub_1ffeh\r
- jr l21a3h\r
+ call tc_set_bp\r
+ jr user_go1\r
\r
l2151h:\r
call bp_clr_temporary\r
call sub_21c8h\r
jr z,l216bh\r
ld hl,b_2048_start\r
- call lookup_opc\r
+ call lookup_op\r
jr nc,l214ch\r
l216bh:\r
- ld a,(trace_UW_flag)\r
+ ld a,(trace_UW_flag) ;0 or 'U' or 'W'\r
and a\r
- jr z,l2188h\r
- ld de,(trace_count)\r
+ jr z,tc_cnt ;flag is 0, check for step count.\r
+ ld de,(trace_cnt_or_ptr)\r
call expr\r
ld a,h\r
or l\r
add a,0ffh\r
sbc a,a\r
- ld hl,trace_UW_flag\r
+ ld hl,trace_UW_flag ;'U' or 'W'\r
xor (hl)\r
- bit 1,a\r
+ bit 1,a ;'U' = 55H, 'W' = 57H\r
jr z,l2193h\r
-l2185h:\r
- jp l0902h\r
-l2188h:\r
- ld hl,(trace_count)\r
+do_break0: ;print registers and go to main loop\r
+ jp do_break\r
+\r
+tc_cnt:\r
+ ld hl,(trace_cnt_or_ptr)\r
dec hl\r
- ld (trace_count),hl\r
+ ld (trace_cnt_or_ptr),hl\r
ld a,h\r
or l\r
- jr z,l2185h\r
+ jr z,do_break0\r
l2193h:\r
- call sub_1ffeh\r
- jr nc,l2185h\r
+ call tc_set_bp\r
+ jr nc,do_break0\r
ld a,(trace_N_flag)\r
ld b,a\r
- ld a,(l0941h)\r
+ ld a,(bp_p_cpu_flag)\r
or b\r
- ld (l0941h),a\r
-l21a3h:\r
+ ld (bp_p_cpu_flag),a\r
+user_go1:\r
jp user_go\r
\r
-sub_21a6h:\r
+tc_chk_u_or_w:\r
call skipbl\r
xor a\r
ld (trace_UW_flag),a\r
\r
;-------------------------------------------------------------------------------\r
\r
+con_col:\r
+ db 0\r
+\r
+;-------------------------------------------------------------------------------\r
+\r
b_21e2_start:\r
db 0\r
trace_call_flag:\r
db 0 ;1=call, 0=trace\r
trace_UW_flag:\r
db 0 ;0 or 'U' or 'W'\r
-trace_count:\r
+trace_cnt_or_ptr:\r
dw 0\r
trace_N_flag:\r
db 0 ;0 if 'N'\r
trace_J_flag:\r
db 0 ;0 if 'J'\r
\r
-;-------------------------------------------------------------------------------\r
-\r
-con_col:\r
- db 0\r
-\r
-l0941h:\r
+bp_p_cpu_flag:\r
db 0\r
\r
bp_tab:\r
\r
expr_p1:\r
dw expr_buf\r
-expr_p2:\r
- dw expr_buf\r
\r
expr_buf:\r
current_cseg defl $ - current_cseg\r