wiz-lang / wiz

A high-level assembly language for writing homebrew software and games on retro console platforms.
http://wiz-lang.org/
Other
409 stars 40 forks source link

if statements with multiple && expressions emits incorrect code. #63

Closed undisbeliever closed 5 years ago

undisbeliever commented 5 years ago

Wiz is not emitting the correct code if a conditional statement contains more than one &&.

The following code (taken from 6502_goto_and_or.wiz)

LogicalAndTestLabel:
    goto LogicalAndTestLabel if
        a == 100
        && a != 42
        && a < zp_u8_00
        && a >= ram_u8_200
        && a <= zp_u8_01
        && a > ram_u8_201;

is somehow emitting the following invalid mess:

`--> r2 -a6502 -m0x8000 obj/6502_goto_and_or.6502.bin
WARNING: using oba to load the syminfo from different mapaddress.
TODO: Must use the API instead of running commands to speedup loading times.
 -- Feed the bugs!
[0x00008000]> e scr.utf8 = true
[0x00008000]> e asm.bytespace=true
[0x00008000]> pd 15
        ┌─> 0x00008000      c9 64                 cmp #0x64
       ┌──< 0x00008002      d0 04                 bne 0x008008
       │╎   0x00008004      c9 2a                 cmp #0x2a
      ┌───< 0x00008006      d0 09                 bne 0x008011
      │└──> 0x00008008      c5 00                 cmp 0x00
      │┌──< 0x0000800a      90 05                 bcc 0x008011
      ││╎   0x0000800c      cd 00 02              cmp 0x0200
     ┌────< 0x0000800f      b0 0d                 bcs 0x00801e
     │└└──> 0x00008011      c5 01                 cmp 0x01
     │ ┌──< 0x00008013      f0 09                 beq 0x00801e
     │┌───< 0x00008015      90 07                 bcc 0x00801e
     │││╎   0x00008017      cd 01 02              cmp 0x0201
    ┌─────< 0x0000801a      f0 02                 beq 0x00801e
    ││││└─< 0x0000801c      b0 e2                 bcs 0x008000
    └└└└──> 0x0000801e