You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
472 B
C
36 lines
472 B
C
4 months ago
|
#include <stdio.h>
|
||
|
#include <stdint.h>
|
||
|
|
||
|
extern int32_t sp;
|
||
|
extern int32_t stack;
|
||
|
|
||
|
void emit()
|
||
|
{
|
||
|
putchar(*(&stack + --sp));
|
||
|
}
|
||
|
|
||
|
void sub()
|
||
|
{
|
||
|
int32_t *st = &stack;
|
||
|
st[sp - 2] -= st[sp - 1];
|
||
|
--sp;
|
||
|
}
|
||
|
|
||
|
void cswap()
|
||
|
{
|
||
|
int32_t *st = &stack;
|
||
|
--sp;
|
||
|
if (st[sp]) {
|
||
|
int32_t tmp = st[sp - 1];
|
||
|
st[sp - 1] = st[sp - 2];
|
||
|
st[sp - 2] = tmp;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void eq()
|
||
|
{
|
||
|
int32_t *st = &stack;
|
||
|
--sp;
|
||
|
st[sp - 1] = st[sp - 1] == st[sp];
|
||
|
}
|