aboutsummaryrefslogtreecommitdiffstats
path: root/foci.h
diff options
context:
space:
mode:
Diffstat (limited to 'foci.h')
-rw-r--r--foci.h22
1 files changed, 13 insertions, 9 deletions
diff --git a/foci.h b/foci.h
index 9a87723..3f745a5 100644
--- a/foci.h
+++ b/foci.h
@@ -27,7 +27,7 @@
#define WORD(name, tname, prev, attr) \
extern const void *name##_body[]; \
- struct word_t w_##name = { \
+ const struct word_t w_##name = { \
name##_body, prev, attr + sizeof(tname) - 1, tname \
}; \
const void *name##_body[] = {
@@ -37,7 +37,7 @@
#define NATIVE(name, tname, prev, attr) \
extern const void *name##_body[]; \
NAKED void name(void); \
- struct word_t w_##name = { \
+ const struct word_t w_##name = { \
name##_body, prev, \
(attr | ATTR_NATIVE) + sizeof(tname) - 1, tname \
}; \
@@ -54,19 +54,22 @@
struct word_t
{
const void **body;
- struct word_t *prev;
+ const struct word_t *prev;
unsigned char attr;
char name[];
} __attribute__ ((packed));
+#ifdef FOCI_ARM
// ARM Cortex-M:
-//register intptr_t * sp asm("r0"); // pointer to stack cells
-//register intptr_t *** rp asm("r1"); // stack of pp
-//register intptr_t ** pp asm("r2"); // pointer to ip
-//register intptr_t tmp asm("r8");
-//#define STASH asm("push {r0-r2,r8}")
-//#define RESTORE asm("pop {r0-r2,r8}")
+register intptr_t * sp asm("r0"); // pointer to stack cells
+register intptr_t *** rp asm("r1"); // stack of pp
+register intptr_t ** pp asm("r2"); // pointer to ip
+register intptr_t tmp asm("r8");
+#define STASH asm("push {r0-r2,r8}")
+#define RESTORE asm("pop {r0-r2,r8}")
+#endif // FOCI_ARM
+#ifdef FOCI_X86_64
// x86_64
register intptr_t * sp asm("r12"); // pointer to stack cells
register intptr_t *** rp asm("r13"); // stack of pp
@@ -74,6 +77,7 @@ register intptr_t ** pp asm("r14"); // pointer to ip
register intptr_t tmp asm("r15");
#define STASH asm("push %r12; push %r13; push %r14")
#define RESTORE asm("pop %r14; pop %r13; pop %r12")
+#endif // FOCI_X86_64
extern void foci_putchar(int);
extern int foci_getchar(void);