/macros.inc
// defines a pascal string
// currently unused
.macro pstring str:req
	.byte 2f - 1f
1:
	.ascii "\str"
2:
.endm

// pushes r0 to the control stack
.macro push_cs
	mov r2, r9
	stm r2!, {r0}
	mov r9, r2
.endm

// pops r0 from the control stack
.macro pop_cs
	mov r2, r9
	sub r2, #4
	mov r9, r2
	ldr r0, [r2]
.endm

// peeks the top of the control stack into r0
.macro peek_cs
	mov r2, r9
	sub r2, #4
	ldr r0, [r2]
.endm

.equ WF_COMPILE_TIME, 1<<0

// start definition of a word
.macro def_word name:req compile_time=0 inline=0
	.align 2
\name:
	.short _\name\()_end - \name              // total size (aka offset to next word)
	.short _\name\()_code_end - _\name        // code length
.if \compile_time
	.word _\name\()_ctsupp                    // reference to a compile-time fixup function
.else
	.word 0
.endif
	.byte _\name\()_name_end - _\name\()_code_end  // name length
	.byte (\inline << 0)
_\name:
.endm

// end definition of a word. `name` must match the start definition
.macro def_end name:req
_\name\()_code_end:
	.ascii "\name"
_\name\()_name_end:
.align 2
_\name\()_end:
.endm