From e62e96878513fc4296ce6c5b8ac29234b9719e23 Mon Sep 17 00:00:00 2001 From: Ketmar Dark Date: Fri, 14 Aug 2020 11:15:45 +0300 Subject: [PATCH] fixed bug with "0BEEFH" -- it was "not a number", because of "0b" prefix --- main.zas | 4 +++- parser.zas | 28 ++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/main.zas b/main.zas index 3557e94..403ee4a 100644 --- a/main.zas +++ b/main.zas @@ -134,12 +134,14 @@ strbuf: defm "exx",13 defm "ld hl,#4001",13 defm "ld a,(ix-2)",13 - defm "call BEEFh",13 + defm "call 0BEEFh",13 defm "or c",13 defm "and (hl)",13 defm "jr $",13 defm "ld de,$1234",13 defm "ld bc,0x5b02",13 + defm "ld a,0b1001",13 + defm "ld a,%1010",13 defb 0 dest: defs 64,0 diff --git a/parser.zas b/parser.zas index 73bbb43..292a23b 100644 --- a/parser.zas +++ b/parser.zas @@ -105,7 +105,10 @@ PARSE_NUMBER: call convDigit jp c,.not_a_number_carry_set cp 10 - jp nc,.must_be_hex_with_sfx + ; nope, do not allow it, all numbers must start with a digit + ;jp nc,.must_be_hex_with_sfx + ccf + jp c,.not_a_number_carry_set .do_normal_decimal: ; done with prefixes, try decimal number ; we'll switch to suffix checking on hex digit @@ -134,7 +137,7 @@ PARSE_NUMBER: ld a,(iy) and %11011111 ; cheap uppercase cp 'H' - jr z,.must_be_hex_with_sfx + jp z,.must_be_hex_with_sfx cp 'B' jp z,.bin_with_sfx cp 'O' @@ -151,7 +154,7 @@ PARSE_NUMBER: inc iy call .parse_as_hex .after_prefix: - jr c,.not_a_number_carry_set + jp c,.not_a_number_carry_set jr .success .maybe_lone_dollar: @@ -172,6 +175,19 @@ PARSE_NUMBER: call .parse_as_bin jr .after_prefix +.maybe_binprefix: + ; things like "0BEEFh" should be parsed as hex + ; skip prefix + inc iy + call .parse_as_bin + jr c,.must_be_hex_with_sfx + ; check for 'H' + ld a,(iy) + and %11011111 ; cheap uppercase + cp 'H' + jr z,.must_be_hex_with_sfx + jr .success + .octprefix: ; skip prefix inc iy @@ -191,13 +207,13 @@ PARSE_NUMBER: cp 'X' jr z,.hexprefix cp 'B' - jr z,.binprefix + jr z,.maybe_binprefix cp 'O' jr z,.octprefix cp 'D' jr z,.parse_as_dec ; do not reparse '0', no need to backup - jr .do_normal_decimal + jp .do_normal_decimal .parse_as_dec: ; skip prefix @@ -242,7 +258,7 @@ PARSE_NUMBER: inc iy and %11011111 ; cheap uppercase cp 'H' - jr z,.success + jp z,.success .not_a_number: scf -- 2.11.4.GIT