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

Bugs in handling runtime address-of expressions. #110

Open Bananattack opened 3 years ago

Bananattack commented 3 years ago

Currently if you write an expression like:

var array : [u8; 32];
// ...
bc = 10;
hl = &array[bc] as u16;

it results in a fairly nonsensical-looking compilation error.

This should however, map into a simple load + add expression. It should be equivalent to:

hl = &array as u16 + bc;

or in Z80:

ld hl, array
add hl, bc

Figure out why address-of operator isn't able to rewrite the index expression into address arithmetic in this case. Do the same fix for unaligned indexing.

Note that something like this seems to work fine, because compile/link-time expressions get handled differently, and it is able to fold the expression together at compile-time:

hl = &array[10];