Created
August 3, 2011 11:34
-
-
Save bkerley/1122420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "symbol.h" | |
#include "init.h" | |
void JJ() | |
{ | |
long a,b,r; | |
a = (long)stack_pop(); // (long)stack_pop() turns into this | |
b = (long)stack_pop(); | |
r = a + b; | |
stack_push((stack_entry)r); // stack_push((stack_entry)r) turns into this | |
} | |
void JI() | |
{ | |
long a,b,r; // binop(a * b) turns into this whole function | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
r = a * b; | |
stack_push((stack_entry)r); | |
} | |
void JL() | |
{ | |
long a,b,r; | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
r = b - a; | |
stack_push((stack_entry)r); | |
} | |
void JN() | |
{ | |
long a,b,r; | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
r = b / a; | |
stack_push((stack_entry)r); | |
} | |
void IN() | |
{ | |
long a,b,r; | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
r = b % a; | |
stack_push((stack_entry)r); | |
} | |
void JFKOFFF() | |
{ | |
long a,b,r; | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
r = b << a; | |
stack_push((stack_entry)r); | |
} | |
void JGOJIFF() | |
{ | |
long a,b,r; | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
r = b >> a; | |
stack_push((stack_entry)r); | |
} | |
void GHI() | |
{ | |
long a,b; | |
a = (long)stack_pop(); | |
b = (long)stack_pop(); | |
stack_push((stack_entry)a); | |
stack_push((stack_entry)b); | |
} | |
void OLGMGHOMN() | |
{ | |
long a; | |
a = (long)stack_pop(); | |
printf("%ld\n",a); | |
} | |
void JMFKNFOGN() | |
{ | |
long a; | |
a = (long)stack_pop(); | |
printf("0x%lx\n",a); | |
} | |
void init_register() { | |
symbol_cbind("+", *JJ); | |
symbol_cbind("*", *JI); | |
symbol_cbind("-", *JL); | |
symbol_cbind("/", *JN); | |
symbol_cbind("%", *IN); | |
symbol_cbind("<<", *JFKOFFF); | |
symbol_cbind(">>", *JGOJIFF); | |
symbol_cbind("x", *GHI); | |
symbol_cbind("pop", *OLGMGHOMN); | |
symbol_cbind("pop.x", *JMFKNFOGN); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment