diff --git a/il65/astparse.py b/il65/astparse.py index c56e3c488..85a0d4604 100644 --- a/il65/astparse.py +++ b/il65/astparse.py @@ -108,7 +108,7 @@ def parse_expr_as_comparison(text: str, sourceref: SourceRef) -> Tuple[str, str, }[node.body.ops[0].__class__.__name__] if not operator: raise src.to_error("unsupported comparison operator") - left = text[node.body.left.col_offset:node.body.comparators[0].col_offset-len(operator)] + left = text[node.body.left.col_offset:node.body.comparators[0].col_offset].rstrip()[:-len(operator)] right = text[node.body.comparators[0].col_offset:] return left.strip(), operator, right.strip() left = astnode_to_repr(node.body) diff --git a/lib/c64lib.ill b/lib/c64lib.ill index de0355521..81cfaacdd 100644 --- a/lib/c64lib.ill +++ b/lib/c64lib.ill @@ -219,7 +219,7 @@ sub IOBASE () -> (X, Y) = $FFF3 ; read base address of I/O devices ~ c64util { -sub init_state () -> (A?, X?, Y?) { +sub init_system () -> (A?, X?, Y?) { ; ---- initializes the machine to a sane starting state ; This means that the BASIC, KERNAL and CHARGEN ROMs are banked in, ; the VIC, SID and CIA chips are reset, screen is cleared, and the default IRQ is set. diff --git a/testsource/conditionals.ill b/testsource/conditionals.ill index 724f3c4e7..765a64c31 100644 --- a/testsource/conditionals.ill +++ b/testsource/conditionals.ill @@ -1,4 +1,7 @@ -output raw +output prg,sys + +import "c64lib" + ~ main { var .text name = "?"*80 @@ -8,20 +11,26 @@ output raw start - A = 44 - X = ~22+44 - A= ~-1 - Y = ~-2 + c64util.init_system() + + A = 0 +printloop + c64util.print_byte_decimal(A) + c64.CHROUT('\n') + A++ + if A <20 goto printloop return + label1 - if_true A==0 goto label1 + if_true A==123 goto label1 + if_true A == 123 goto label1 if_true A!=0 goto label1 if_not X!=0 goto label1 - if_true A<=1 goto label1 + if_true A <= 1 goto label1 if_true A==1 goto label1 if_true A!=1 goto label1 - if_not X<1 goto label1 + if_not X < 1 goto label1 if_not Y>1 goto label1 if_not X!=1 goto label1 @@ -31,7 +40,8 @@ label1 if_true X>Y goto label1 if_true X>A goto label1 if A<=22 goto label1 - if_cc A goto label1 + if A <= 22 goto label1 + if_cc A goto label1 if_vc X goto label1 if_pos Y goto label1 if_true XY goto label1 diff --git a/testsource/input.ill b/testsource/input.ill index 1ce3f7795..b79f2e2e7 100644 --- a/testsource/input.ill +++ b/testsource/input.ill @@ -6,7 +6,7 @@ import "c64lib" var .text name = "?"*80 start - c64util.init_state() + c64util.init_system() XY = c64.CINV SI = 1