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

Offset param to load() and store() should be in elements and not bytes? #97

Closed
aduros opened this issue Aug 21, 2021 · 1 comment
Closed

Comments

@aduros
Copy link
Contributor

aduros commented Aug 21, 2021

The pointer arithmetic example at https://www.assemblyscript.org/introduction.html#low-level-perspective seems incorrect:

store<i32>(ptr, load<i32>(ptr) + load<i32>(ptr, 4), 8)

But to match the C example it should be:

store<i32>(ptr, load<i32>(ptr) + load<i32>(ptr, 16), 32)

It looks like load/store offsets are implemented in bytes, but it would be really handy if it used the element size for parity with C.

@MaxGraey MaxGraey transferred this issue from AssemblyScript/assemblyscript Aug 21, 2021
@MaxGraey
Copy link
Member

MaxGraey commented Aug 21, 2021

I moved this issue to website issues.
Regarding snippet. Yes it should be fixed but in C example:

- *(ptr + 8) = *ptr + *(ptr + 4)
+ *(ptr + 2) = *ptr + *(ptr + 1)

offsets should in bytes due to this wasm intrinsics and we can't change original semantics

PR is welcomed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants