aboutsummaryrefslogtreecommitdiff
path: root/pu2/pu2.c
diff options
context:
space:
mode:
authorGravatar Moon Flower <moon@coffin.ir> 2025-08-20 14:15:05 +0330
committerGravatar Moon Flower <moon@coffin.ir> 2025-08-20 14:15:05 +0330
commita6d16990fd6109f569324bb1422bfb603f6d031b (patch)
treedfe95ec2a8740dc8dfd29e4199af56bcd5938015 /pu2/pu2.c
parentthe speedster (diff)
added compat flags for easier cross-compilation
Diffstat (limited to 'pu2/pu2.c')
-rw-r--r--pu2/pu2.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/pu2/pu2.c b/pu2/pu2.c
index 1e3bdf1..076261c 100644
--- a/pu2/pu2.c
+++ b/pu2/pu2.c
@@ -286,7 +286,7 @@ int *Data;
init_ir2() {
Code = &m[ 4000 ];
- Data = &m[ S * sizeof(int) - 1 ]; // grows downwards
+ Data = &m[ S - 1 ]; // grows downwards
}
__attribute__((always_inline)) emit(int op, int val) {
@@ -638,9 +638,13 @@ string op_names[] = { "hlt", "imm", "lod", "str", "swp", "add", "sub", "and", "n
"a2u", "u2a", "b2u", "u2b", "nop", "cb1", "cb2", "cb3", "cb4" };
unsigned long long rdtsc(void) {
+#ifndef PU2_NO_ASM
unsigned hi, lo;
__asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi));
return ((unsigned long long) hi << 32) | lo;
+#else
+ return 0;
+#endif
}
clock_t ntime() {