-
Notifications
You must be signed in to change notification settings - Fork 2
/
interpret_number.S
141 lines (124 loc) · 2.65 KB
/
interpret_number.S
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# interpret_numbers.S
# ( c -- )
# fetch the lit vector and EXEC it. Will interpret a litteral for one of the registers
Forthword_ LIT_INTERP, 0, "lit.interp"
push_
user_ Lit_Interpret
mw_
end_do_ EXEC
# ( c -- )
# fetch the lit vector and EXEC it. Will compile a litteral for one of the registers
Forthword_ LIT_COMP, 0, "lit.comp"
push_
user_ Lit_Compile
mw_
end_do_ EXEC
# ( xtc xti -- )
# Select register for literal
Forthword_ REGSET, IMMEDIATE_EN, "regset"
rpushy_
y_w_
user_ Lit_Interpret
mw_y_
y_d0_
user_ Lit_Compile
mw_y_
d1_
nip2_
rpopy_
end_
# ( -- )
# Select W register for literal
Forthword_ WSET, IMMEDIATE_EN, "w="
push_
lit_ WLIT_C
push_
lit_ WLIT_INTERP
end_do_ REGSET
# ( -- )
# Select A register for literal
Forthword_ ASET, IMMEDIATE_EN, "a="
push_
lit_ ALIT_C
push_
lit_ ALIT_INTERP
end_do_ REGSET
# ( -- )
# Select B register for literal
Forthword_ BSET, IMMEDIATE_EN, "b="
push_
lit_ BLIT_C
push_
lit_ BLIT_INTERP
end_do_ REGSET
# ( -- )
# Select X register for literal
Forthword_ XSET, IMMEDIATE_EN, "x="
push_
lit_ XLIT_C
push_
lit_ XLIT_INTERP
end_do_ REGSET
# ( -- )
# Select Y register for literal
Forthword_ YSET, IMMEDIATE_EN, "y="
push_
lit_ YLIT_C
push_
lit_ YLIT_INTERP
end_do_ REGSET
# ( n -- )
# store n in WR
Forthword_ WLIT_INTERP, IMMEDIATE_EN, "[w=]"
movl %eax, WR
end_
# ( n -- )
# store n in RY
Forthword_ YLIT_INTERP, IMMEDIATE_EN, "[y=]"
movl %eax, RY
end_
# ( n -- )
# store n in RX
Forthword_ XLIT_INTERP, IMMEDIATE_EN, "[x=]"
movl %eax, RX
end_
# ( n -- )
# store n in RA
Forthword_ ALIT_INTERP, IMMEDIATE_EN, "[a=]"
movl %eax, RA
end_
# ( n -- )
# store n in RB
Forthword_ BLIT_INTERP, IMMEDIATE_EN, "[b=]"
movl %eax, RB
end_
# ( addr len -- [n] | [addr len] f )
# recognizer for integer numbers
Forthword_ REC_NUM, 0, "rec#"
rpush_ # ( addr len ) (R: len )
y_d0_ # ( addr len Y:addr )
rpushy_ # ( addr len ) (R: len addr )
# try converting to a number
do_ NUMBER # ( [n] f )
iszero_
if_0_ REC_NONUMBER
rnip2_ # ( n f )
do_ STATE # ( n state )
iszero_
pop_
if_0_ REC_NUMBER_OK
do_ LIT_COMP
goto_ REC_NUMBER_DONE
REC_NUMBER_OK:
do_ LIT_INTERP
REC_NUMBER_DONE:
do_ WSET
true_ # ( true ) (R: )
exit_
REC_NONUMBER:
rpop_ # ( addr ) (R: len )
push_ # ( addr addr ) (R: len )
rpop_ # ( addr len ) (R: )
push_ # ( addr len len )
zero_ # ( addr len 0 )
end_