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:
Currently if you write an expression like:
it results in a fairly nonsensical-looking compilation error.
This should however, map into a simple load + add expression. It should be equivalent to:
or in Z80:
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: