Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in handling runtime address-of expressions. #110

Open
Bananattack opened this issue Feb 7, 2021 · 0 comments
Open

Bugs in handling runtime address-of expressions. #110

Bananattack opened this issue Feb 7, 2021 · 0 comments

Comments

@Bananattack
Copy link
Collaborator

Bananattack commented Feb 7, 2021

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];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant