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

GETGLOB and GETGLOBVAR are mixed up #22

Open
Shvandre opened this issue Jan 3, 2025 · 1 comment
Open

GETGLOB and GETGLOBVAR are mixed up #22

Shvandre opened this issue Jan 3, 2025 · 1 comment
Assignees

Comments

@Shvandre
Copy link
Contributor

Shvandre commented Jan 3, 2025

In opcodes.yaml it is clearly seen, that GETGLOBVAR does not have instruction-encoded argument, while GETGLOB does.

  # A.11.5. Global variable primitives.
  GETGLOBVAR:
  GETGLOB: ["int"]

Same goes for the ton docs.

However in opcodes.ts there is such handling of GETGLOBVAR

CP0Auto.insertHex('f841', 11, (slice) => {
    let i = slice.loadUint(5);
    return { code: `GETGLOBVAR`, args: [i] };
});

And as decompiler output I get

1 GETGLOBVAR

Also, when executing this code in @ton/sandbox I can clearly see that GETGLOB is being executed, not GETGLOBVAR.

Besides, I still do not understand which encoding is correct, and we probably need to fix this in docs too.

@Shvandre Shvandre self-assigned this Jan 3, 2025
@Shvandre
Copy link
Contributor Author

Shvandre commented Jan 5, 2025

Moreover, both opcodes been decoded like GETGLOBVAR. Why?

global int first;
global int second;

(int) test() impure inline asm "ONE ONE ADD GETGLOBVAR";

~impure_touch(test());
~impure_touch(second);

results

1 PUSHINT 
1 PUSHINT 
ADD 
0 GETGLOBVAR 
s0 POP 
1 GETGLOBVAR 
s0 POP 

Which is totally incorrect

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

1 participant