-
Notifications
You must be signed in to change notification settings - Fork 0
/
junk
97 lines (78 loc) · 1.99 KB
/
junk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// two subroutines to store where we are in the execution
// (call trace)
// note that this stack grows upwards. Makes debugging easier
// r1 contains the pointer to the word we want to store
pushforthcall:
push {r5,r6,r7,lr}
ldr r7,=forthframestackptr
ldr r6,[r7] // stack pointer
ldr r5,=forthframestackend
cmp r6,r5
ble _pfc1
// stack is overflowing, print info message
push {r0,r1,r2,r3}
ldr r0,=callstackfullstring
bl printf
pop {r0,r1,r2,r3}
pop {r5,r6,r7,pc}
_pfc1:
str r1,[r6]
add r6,#4 // move pointer
str r6,[r7]
pop {r5,r6,r7,pc}
// this doesn't return anything right now
popforthcall:
push {r5,r6,r7,lr}
ldr r7,=forthframestackptr
ldr r6,[r7] // stack pointer
ldr r5,=forthframestackstart
cmp r6,r5
bge _pfc2
// stack is underflowing, print info message
// message is noisy and not really needed _right now_, ignore and return
// however, this should really not happen...
// push {r0,r1,r2,r3}
// ldr r0,=callstackemptystring
// bl printf
// pop {r0,r1,r2,r3}
pop {r5,r6,r7,pc}
_pfc2:
sub r6,#4
str r6,[r7] // simple discard
pop {r5,r6,r7,pc}
###
## variables
// push {r1} // push B
// ldr r0,=hexnumber
// bl printf
// pop {r1} // pop B
// ldr r3,=FLAG_IMMEDIATE
// and r2,r3
// cmp r2,#0
// bne runthecodeimmediate
// print debug message if the instruction is not "immediate
// ldr r0,=notimmediatemsg
// add r1,#OFFSET_NAME
// bl printf
// pop {r1}
// check for compile time here
// ldr r0, =mode
// ldr r0,[r0]
// cmp r0, #0
//_compilecheck:
// beq runthecode
// // print debug message if we are in compile time or not
// push {r1} // push C
// ldr r0,=compilemsg
// add r1,#OFFSET_NAME
// bl printf
// pop {r1} pop C
// // compile time. Push the word link to HERE, increase HERE with 4
// ldr r0,=freemem // get HERE
// ldr r0,[r0]
// str r1,[r0] // put word link on HERE
// add r0,#INTLEN // increment HERE with INTLEN
// ldr r2,=freemem
// str r0,[r2]
// // once stored, go to the end of the loop and start over again
// b done