jr c,mainloop\r
ret\r
\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
- ret\r
-\r
out.hl.@:\r
call out_hl\r
push de\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
+pstr:\r
+ ld c,0\r
+l028ah:\r
+ ld a,(hl)\r
+ inc hl\r
+ and a\r
+ ret z\r
+ call outchar\r
+ inc c\r
+ and a\r
+ ret m\r
+ jr l028ah\r
+\r
+pstr_inl:\r
+ ex (sp),hl\r
+ call pstr\r
+ ex (sp),hl\r
+ ret\r
+\r
inchar:\r
push hl\r
push de\r
pop hl\r
ret\r
\r
-pstr:\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
-l028ah:\r
- ld a,(hl)\r
- inc hl\r
- and a\r
- ret z\r
- call outchar\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
- and a\r
- ret m\r
- jr l028ah\r
-\r
-pstr_inl:\r
- ex (sp),hl\r
- call pstr\r
- ex (sp),hl\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
-outbl6:\r
- call outbl2\r
-outbl4:\r
- call outbl2\r
-outbl2:\r
- call outbl\r
-outbl:\r
- ld a,' '\r
- jr outchar\r
-\r
-add_hl_a:\r
- add a,l\r
- ld l,a\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
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
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
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