.phase current_phase + current_cseg\r
signon:\r
db 'DDT/180',TAB\r
- db '[8101] 002',CR,LF,'$'\r
+ db '[8101] 003',CR,LF,'$'\r
msgz80:\r
db 'Z80 or better required!',cr,lf,'$'\r
\r
reg.iff:\r
db 0f3h\r
db 0c3h\r
-REG.PC: dw TPA\r
-l0062h: dw 0000h\r
-offs.@: dw 0\r
+reg.pc: dw TPA\r
+var.$: dw 0000h\r
+var.@: dw 0\r
\r
-CMD_ERR:dw l0146h\r
+error_func:dw l0146h\r
cmd_rpt:dw mainloop\r
\r
conbuf:\r
\r
ds CONBUF_SIZE + 3 - ($ - conbuf)\r
\r
+CMDTAB:\r
+ dw cmd_@ ;examine/substitute the displacement register @\r
+ dw cmd_A ;Assemble\r
+ dw cmd_B ;Breakpoints display/set/clear\r
+ dw cmd_C ;trace over Calls\r
+ dw cmd_D ;Display memory in hex and ascii\r
+ dw ERROR ;\r
+ dw cmd_F ;specify Filename and command line\r
+ dw cmd_G ;Go\r
+ dw cmd_H ;compute Hex and other expressions\r
+ dw cmd_I ;Input a byte from port\r
+ dw ERROR ;\r
+ dw ERROR ;\r
+ dw cmd_L ;List disassembled code\r
+ dw cmd_M ;Move memory [and verify]\r
+ dw ERROR ;\r
+ dw cmd_O ;Output a byte to port\r
+ dw ERROR ;\r
+ dw cmd_Q ;Qery memory for byte string\r
+ dw cmd_R ;Read binary or hex file and/or symbol file\r
+ dw cmd_S ;Substitute memory\r
+ dw cmd_T ;Trace\r
+ dw ERROR ;\r
+ dw cmd_V ;Verify (compare) two memory areas\r
+ dw cmd_W ;Write a file to disk\r
+ dw cmd_X ;eXamine [and substitute] registers\r
+ dw cmd_Y ;examine [and substitute] Y variables\r
+ dw cmd_Z ;Zap (fill) memory with a byte string\r
+\r
mainloop:\r
ld sp,stack\r
ld hl,l0146h\r
- ld (CMD_ERR),hl\r
- ld hl,(REG.PC)\r
- ld (l0062h),hl\r
+ ld (error_func),hl\r
+ ld hl,(reg.pc)\r
+ ld (var.$),hl\r
call bp_clr_temporary\r
ld hl,(cmd_rpt)\r
ld de,mainloop\r
ld h,(hl)\r
ld l,a\r
jr exe_hl\r
+\r
ERROR:\r
- ld hl,(CMD_ERR)\r
+ ld hl,(error_func)\r
exe_hl:\r
call CALL_HL\r
jr mainloop\r
\r
-CMDTAB:\r
- dw cmd_@\r
- dw cmd_A\r
- dw cmd_B\r
- dw cmd_C\r
- dw cmd_D\r
- dw ERROR\r
- dw cmd_F\r
- dw cmd_G\r
- dw cmd_H\r
- dw cmd_I\r
- dw ERROR\r
- dw ERROR\r
- dw cmd_L\r
- dw cmd_M\r
- dw ERROR\r
- dw cmd_O\r
- dw ERROR\r
- dw cmd_Q\r
- dw cmd_R\r
- dw cmd_S\r
- dw cmd_T\r
- dw ERROR\r
- dw cmd_V\r
- dw cmd_W\r
- dw cmd_X\r
- dw cmd_Y\r
- dw cmd_Z\r
-\r
l0146h:\r
ld a,'?'\r
call outchar\r
- jp crlf\r
-get_line:\r
- push hl\r
- ld de,conbuf\r
- ld c,BDOS_CBUF\r
- call ddtz_bdos\r
- call crlf\r
- ld de,conbuf+1\r
- ld a,(de)\r
- ld b,a\r
- ld c,0\r
- inc b\r
-l0162h:\r
- inc de\r
- dec b\r
- jr z,l0194h\r
- ld a,(de)\r
- bit 0,c\r
- call z,toupper\r
- ld (de),a\r
- cp ''''\r
- jr nz,l0162h\r
- push de\r
- dec de\r
- ld a,(de)\r
- cp ''''\r
- jr z,l0190h\r
- dec de\r
- ld a,(de)\r
- cp '^'\r
- jr z,l0184h\r
- dec de\r
- ld a,(de)\r
- cp '^'\r
- jr nz,l0190h\r
-l0184h:\r
- inc de\r
- push bc\r
- call sub_0303h\r
- pop bc\r
- dec de\r
- ld a,(de)\r
- cp ''''\r
- jr z,l0191h\r
-l0190h:\r
- inc c\r
-l0191h:\r
- pop de\r
- jr l0162h\r
-l0194h:\r
- xor a\r
- ld (de),a\r
- ld de,conbuf+2\r
- pop hl\r
- ret\r
-\r
-toupper:\r
- cp 'a'\r
- ret c\r
- cp 'z'+1\r
- ret nc\r
- and 05fh\r
+ ;fall thru\r
+crlf:\r
+ call inchar\r
+ ld a,CR\r
+ call outchar\r
+ ld a,LF\r
+ call outchar\r
+ ld a,0\r
+ ld (con_col),a\r
+ jr c,mainloop\r
ret\r
\r
out.hl.@:\r
call out_hl\r
push de\r
push hl\r
- ld de,(offs.@)\r
+ ld de,(var.@)\r
ld a,d\r
or e\r
jr z,l01bfh\r
pop hl\r
pop de\r
ret\r
-out.bin.w:\r
- ld a,h\r
- call out.bin.b\r
- ld a,l\r
-out.bin.b:\r
- ld b,8\r
-l01c9h:\r
- add a,a\r
- push af\r
- ld a,00\r
- adc a,a\r
- call out_dgt\r
- pop af\r
- djnz l01c9h\r
- ld a,'"'\r
- jp outchar\r
\r
sub_01d9h:\r
ld a,'-'\r
l0229h:\r
add a,'0'\r
jr outchar\r
-l022dh:\r
- ld a,'-'\r
- call outchar\r
- ld a,040h\r
+\r
+out.bin.w:\r
+ ld a,h\r
+ call out.bin.b\r
+ ld a,l\r
+out.bin.b:\r
+ ld b,8\r
+l01c9h:\r
+ add a,a\r
+ push af\r
+ ld a,00\r
+ adc a,a\r
+ call out_dgt\r
+ pop af\r
+ djnz l01c9h\r
+ ld a,'"'\r
+ jr outchar\r
+\r
out.ascii:\r
- ex af,af'\r
- call outquote\r
- ex af,af'\r
push af\r
res 7,a\r
cp ' '\r
+ push af\r
+ call nc,outbl\r
+ call outquote\r
+ pop af\r
jr nc,l0242h\r
sub 0c0h\r
+ ex af,af'\r
+ ld a,'^'\r
+ call outchar\r
+ ex af,af'\r
l0242h:\r
call outchar\r
- push af\r
cp ''''\r
call z,outchar\r
- pop af\r
ex af,af'\r
call outquote\r
pop af\r
ld a,'.'\r
call m,outchar\r
ex af,af'\r
- jr c,l022dh\r
ret\r
\r
+outbl6:\r
+ call outbl2\r
+outbl4:\r
+ call outbl2\r
+outbl2:\r
+ call outbl\r
+outbl:\r
+ ld a,' '\r
+ jr outchar\r
+\r
p_char_lparen:\r
ld a,'('\r
jr outchar\r
pop hl\r
ret\r
\r
-inchar:\r
- push hl\r
- push de\r
- push bc\r
- ld c,BDOS_CSTAT\r
- call ddtz_bdos\r
- and a\r
- jr z,l0284h\r
- ld c,BDOS_CIN\r
- call ddtz_bdos\r
- scf\r
-l0284h:\r
- pop bc\r
- pop de\r
- pop hl\r
- ret\r
pstr:\r
ld c,0\r
l028ah:\r
ex (sp),hl\r
ret\r
\r
-outbl6:\r
- call outbl2\r
-outbl4:\r
- call outbl2\r
-outbl2:\r
- call outbl\r
-outbl:\r
- ld a,' '\r
- jr outchar\r
-crlf:\r
- call inchar\r
- ld a,CR\r
- call outchar\r
- ld a,LF\r
- call outchar\r
- ld a,0\r
- ld (con_col),a\r
- jp c,mainloop\r
+inchar:\r
+ push hl\r
+ push de\r
+ push bc\r
+ ld c,BDOS_CSTAT\r
+ call ddtz_bdos\r
+ and a\r
+ jr z,l0284h\r
+ ld c,BDOS_CIN\r
+ call ddtz_bdos\r
+ scf\r
+l0284h:\r
+ pop bc\r
+ pop de\r
+ pop hl\r
ret\r
\r
-add_hl_a:\r
- add a,l\r
- ld l,a\r
+get_line:\r
+ push hl\r
+ ld de,conbuf\r
+ ld c,BDOS_CBUF\r
+ call ddtz_bdos\r
+ call crlf\r
+ ld de,conbuf+1\r
+ ld a,(de)\r
+ ld b,a\r
+ ld c,0\r
+ inc b\r
+l0162h:\r
+ inc de\r
+ dec b\r
+ jr z,l0194h\r
+ ld a,(de)\r
+ bit 0,c\r
+ call z,toupper\r
+ ld (de),a\r
+ cp ''''\r
+ jr nz,l0162h\r
+ push de\r
+ dec de\r
+ ld a,(de)\r
+ cp ''''\r
+ jr z,l0190h\r
+ dec de\r
+ ld a,(de)\r
+ cp '^'\r
+ jr z,l0184h\r
+ dec de\r
+ ld a,(de)\r
+ cp '^'\r
+ jr nz,l0190h\r
+l0184h:\r
+ inc de\r
+ push bc\r
+ call sub_0303h\r
+ pop bc\r
+ dec de\r
+ ld a,(de)\r
+ cp ''''\r
+ jr z,l0191h\r
+l0190h:\r
+ inc c\r
+l0191h:\r
+ pop de\r
+ jr l0162h\r
+l0194h:\r
+ xor a\r
+ ld (de),a\r
+ ld de,conbuf+2\r
+ pop hl\r
+ ret\r
+\r
+toupper:\r
+ cp 'a'\r
+ ret c\r
+ cp 'z'+1\r
ret nc\r
- inc h\r
+ and 05fh\r
ret\r
\r
skipbl0:\r
jr c,to_error\r
ret\r
\r
+add_hl_a:\r
+ add a,l\r
+ ld l,a\r
+ ret nc\r
+ inc h\r
+ ret\r
+\r
cp_hl_de:\r
and a\r
sbc hl,de\r
ld hl,TPA\r
cp 'L'\r
ret z\r
- ld hl,(offs.@)\r
+ ld hl,(var.@)\r
cp '@'\r
ret z\r
- ld hl,(l0062h)\r
+ ld hl,(var.$)\r
cp '$'\r
ret z\r
cp '-'\r
cp '('\r
jr z,fact_mem\r
cp '['\r
- jp z,expr_brckt\r
+ jr z,expr_brckt\r
cp ''''\r
jr z,fact_factstring\r
+ cp '.'\r
+ jr z,fact_symbol\r
dec de\r
scf\r
ret\r
\r
fact_reg.Y:\r
call get.decdigit\r
- jp c,ERROR\r
+ jr c,error4\r
inc de\r
add a,a\r
ld hl,reg_Y\r
error4:\r
jp ERROR\r
\r
+fact_symbol:\r
+ push bc\r
+ ld hl,ddtz_base\r
+\r
+fs_nxtsym:\r
+ ld a,(hl) ;symlen\r
+ cp 0c3h\r
+ jr z,error4\r
+ ld b,a\r
+ inc b\r
+ push hl\r
+ push de\r
+fs_2:\r
+ ld a,(de)\r
+ call test_termchar\r
+ jr z,fs_endstr\r
+ dec b\r
+ jr z,fs_cont\r
+ inc de\r
+ dec hl\r
+ cp (hl)\r
+ jr z,fs_2\r
+fs_cont:\r
+ pop de\r
+ pop hl\r
+ ld a,(hl)\r
+ add a,3\r
+ call sub_hl_a\r
+ jr fs_nxtsym\r
+\r
+fs_endstr:\r
+ dec b\r
+ jr nz,fs_cont\r
+ pop hl\r
+ pop hl\r
+ inc hl\r
+ ld a,(hl)\r
+ inc hl\r
+ ld h,(hl)\r
+ ld l,a\r
+ or a\r
+ pop bc\r
+ ret\r
+\r
+t_trmchrs:\r
+ db ' !#&()*+,-/:;<=>[\]{|}',0\r
+t_trmchrs_len equ $ - t_trmchrs\r
+\r
+test_termchar:\r
+ push hl\r
+ push bc\r
+ ld hl,t_trmchrs\r
+ ld bc,t_trmchrs_len\r
+ cpir\r
+ pop bc\r
+ pop hl\r
+ ret\r
+\r
+\r
+\r
get.number:\r
call get.hexdigit\r
ret c\r
djnz l063eh\r
push hl\r
push de\r
- ld iy,(REG.PC)\r
+ ld iy,(reg.pc)\r
call p_disas_instr\r
exx\r
ex af,af'\r
db 001h\r
dw reg_sp\r
db 001h\r
- dw REG.PC\r
+ dw reg.pc\r
db 002h\r
dw reg.a2\r
db 000h\r
ld (l0941h),a\r
call expr\r
jr c,l0740h\r
- ld (REG.PC),hl\r
+ ld (reg.pc),hl\r
l0740h:\r
call skipbl\r
jp z,user_go\r
ld (reg.l),hl\r
pop hl\r
dec hl\r
- ld (REG.PC),hl\r
+ ld (reg.pc),hl\r
ld (reg_sp),sp\r
ld sp,reg.l\r
push de\r
jr z,l0938h\r
ld e,(ix+002h)\r
ld d,(ix+003h)\r
- ld hl,(REG.PC)\r
+ ld hl,(reg.pc)\r
call cp_hl_de\r
push bc\r
call z,sub_0942h\r
jr z,l09c0h\r
ld e,(ix+002h)\r
ld d,(ix+003h)\r
- ld hl,(REG.PC)\r
+ ld hl,(reg.pc)\r
call cp_hl_de\r
ret z\r
l09c0h:\r
db 003h\r
dw reg_sp\r
db 003h\r
- dw REG.PC\r
+ dw reg.pc\r
db 003h\r
dw reg.ix\r
db 003h\r
db 003h\r
dw reg_sp\r
db 003h\r
- dw REG.PC\r
+ dw reg.pc\r
db 000h\r
dw reg.i\r
db 003h\r
\r
cmd_@:\r
call assert_eol\r
- ld hl,msg_offset\r
- ld de,offs.@\r
+ ld hl,msg_@\r
+ ld de,var.@\r
ld c,001h\r
jp l0c12h\r
\r
-msg_offset:\r
+msg_@:\r
dc '@'\r
\r
cmd_I:\r
push de\r
push bc\r
call cp_hl_de\r
- jr nc,$+11\r
+ jr nc,cmdm_up\r
add hl,bc\r
ex de,hl\r
add hl,bc\r
dec hl\r
dec de\r
lddr\r
- ld bc,0b0edh\r
+ db 01h ;swallow ldir instruction (ld bc,...)\r
+cmdm_up:\r
+ ldir\r
pop bc\r
pop de\r
pop hl\r
ret\r
\r
cmd_H:\r
+ ld a,(de)\r
+ cp 'S'\r
+ jr z,p_symbols\r
+\r
call expr\r
jp c,p_max_high0\r
call next_arg\r
call out_hl_dec_neg\r
call outbl4\r
call out.bin.w\r
- call outbl2\r
+ call outbl\r
ld a,l\r
call out.ascii\r
+ call outbl\r
+ call p_symbol\r
jp crlf\r
\r
+p_symbols:\r
+ inc de\r
+ call assert_eol\r
+ ld hl,ddtz_base+2\r
+psym_l:\r
+ ld d,(hl)\r
+ dec hl\r
+ ld e,(hl)\r
+ dec hl\r
+ ld b,(hl)\r
+ dec hl\r
+ ld a,b\r
+ cp 0c3h\r
+ ret z\r
+\r
+ ex de,hl\r
+ call out_hl\r
+ ex de,hl\r
+ call outbl\r
+psymch_l:\r
+ ld a,(hl)\r
+ dec hl\r
+ call outchar\r
+ djnz psymch_l\r
+ call crlf\r
+ jr psym_l\r
+\r
+\r
+p_symbol:\r
+ if 0\r
+ ld a,(dash_flag)\r
+ or a\r
+ ret nz\r
+ endif\r
+ call sym_getname\r
+ ret z\r
+ ld a,'.'\r
+ call outchar\r
+p_symstr:\r
+ ld b,(hl)\r
+pss_l:\r
+ dec hl\r
+ ld a,(hl)\r
+ call outchar\r
+ djnz pss_l\r
+ ret\r
+\r
+p_label:\r
+ if 0\r
+ ld a,(dash_flag)\r
+ or a\r
+ ret nz\r
+ endif\r
+ push hl\r
+ call sym_getname\r
+ jr z,pl_e\r
+ call p_symstr\r
+ ld a,':'\r
+ call outchar\r
+ call crlf\r
+pl_e:\r
+ pop hl\r
+ ret\r
+\r
+sym_getname:\r
+ push de\r
+ push hl\r
+ ld hl,ddtz_base+2\r
+sgn_l:\r
+ ld d,(hl)\r
+ dec hl\r
+ ld e,(hl)\r
+ dec hl\r
+ ld a,(hl)\r
+ cp 0c3h\r
+ jr z,sgn_e\r
+\r
+ ex (sp),hl\r
+ call cp_hl_de\r
+ jr z,sgn_e\r
+ ex (sp),hl\r
+ call sub_hl_a1\r
+ jr sgn_l\r
+sgn_e:\r
+ sub 0c3h\r
+ pop hl\r
+ pop de\r
+ ret\r
+\r
+sub_hl_a1:\r
+ dec hl\r
+sub_hl_a:\r
+ push bc\r
+ ld c,a\r
+ ld b,0\r
+ or a\r
+ sbc hl,bc\r
+ pop bc\r
+ ret\r
+\r
cmd_Q:\r
ld a,(de)\r
sub 'J'\r
DC ' Max = '\r
ld hl,(max_load)\r
call out_hl\r
+ call pstr_inl\r
+ DC ' Top = '\r
+ ld hl,(BDOS+1)\r
+ call out_hl\r
jp crlf\r
\r
cmd_W:\r
push hl\r
pop iy\r
ld hl,l1259h\r
- ld (CMD_ERR),hl\r
+ ld (error_func),hl\r
ld (l1262h),sp\r
l1211h:\r
push iy\r
pop hl\r
ld (last_A),hl\r
- ld (l0062h),hl\r
+ ld (var.$),hl\r
push hl\r
call p_disas_line\r
pop iy\r
ld c,b\r
- ld de,(offs.@)\r
+ ld de,(var.@)\r
ld a,d\r
or e\r
ld b,011h\r
ld b,0\r
add iy,bc\r
jr l1211h\r
+\r
l1259h:\r
call l0146h\r
ld sp,(l1262h)\r
jr l190fh\r
\r
p_disas_line:\r
+ call p_label\r
+ call outbl2\r
call out.hl.@\r
call z,outbl\r
call outbl\r
jr c,l193fh\r
\r
p_offset:\r
- ld de,(offs.@)\r
+ ld de,(var.@)\r
ld a,d\r
or e\r
ret z\r
DB 0\r
\r
sub_1ffeh:\r
- ld hl,(REG.PC)\r
+ ld hl,(reg.pc)\r
ld a,h\r
or l\r
jr z,l2037h\r
sbc hl,de\r
ld hl,l20edh\r
jr z,l2031h\r
- ld iy,(REG.PC)\r
+ ld iy,(reg.pc)\r
call disas_get_instrlen\r
jp nc,ERROR\r
ld c,b\r
ld b,000h\r
- ld hl,(REG.PC)\r
+ ld hl,(reg.pc)\r
add hl,bc\r
call sub_09cah\r
- ld iy,(REG.PC)\r
+ ld iy,(reg.pc)\r
ld hl,b_2039_start\r
call lookup_opc\r
ccf\r
rla\r
sbc a,a\r
ld b,a\r
- ld hl,(REG.PC)\r
+ ld hl,(reg.pc)\r
add hl,bc\r
inc hl\r
inc hl\r
ld a,(trace_J_flag)\r
and a\r
jr nz,l216bh\r
- ld iy,(REG.PC)\r
+ ld iy,(reg.pc)\r
call sub_21c8h\r
jr z,l216bh\r
ld hl,b_2048_start\r