Skip to content

Instantly share code, notes, and snippets.

@Blecki
Created April 8, 2012 19:29
Show Gist options
  • Save Blecki/2339468 to your computer and use it in GitHub Desktop.
Save Blecki/2339468 to your computer and use it in GitHub Desktop.
function foo(a) { return 9 + a; }
function test(a,b,c,d,e)
{
a = foo(a);
return ((a + b + c) * d / a) + (d * e);
}
var some_var = 3;
var ret = test(1,2,3,4,5);
some_var = some_var + ret;
SET PUSH, 0x0003
SET A, 0x0001
SET B, 0x0002
SET C, 0x0003
SET PUSH, 0x0004
SET PUSH, 0x0005
JSR LABEL1_test
ADD SP, 0x0002
SET PUSH, A
SET Y, PEEK
SET J, SP
SET X, [0x0001+J]
ADD X, Y
SET J, SP
SET [0x0001+J], X
BRK
:LABEL0_foo
SET C, A
SET B, 0x0009
ADD B, C
SET A, B
SET PC, POP
SET PC, POP
:LABEL1_test
SET PUSH, A
SET PUSH, B
SET PUSH, C
JSR LABEL0_foo
SET J, A
SET C, POP
SET B, POP
SET A, POP
SET A, J
SET J, SP
SET Z, [0x0001+J]
SET J, SP
SET Y, [0x0002+J]
MUL Y, Z
SET Z, A
SET J, SP
SET I, [0x0002+J]
SET PUSH, C
SET PUSH, B
SET X, A
ADD X, POP
ADD X, POP
MUL X, I
DIV X, Z
ADD X, Y
SET A, X
SET PC, POP
SET PC, POP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment