-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecin.tasm
192 lines (150 loc) · 3.02 KB
/
decin.tasm
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# decin -- balanced ternary and decimal number input routines
# see also decin.design
### limits needs and details:
# namespace:
# decin.* key.*
gotodata;>decin.init
null;000000000;decin.number
null;000000000;decin.count
null;0000000+0;decin.base
null;;decin.digit
setkeyint;:+;decin.init
keyint;>key.plus
setkeyint;:-
keyint;>key.minus
setkeyint;:enter
keyint;>key.enter
# <seq 0 9 | sed 's/(.)/setkeyint;:\1\nkeyint;>key.\1/'
#[
setkeyint;:0
keyint;>key.0
setkeyint;:1
keyint;>key.1
setkeyint;:2
keyint;>key.2
setkeyint;:3
keyint;>key.3
setkeyint;:4
keyint;>key.4
setkeyint;:5
keyint;>key.5
setkeyint;:6
keyint;>key.6
setkeyint;:7
keyint;>key.7
setkeyint;:8
keyint;>key.8
setkeyint;:9
keyint;>key.9
#]
null;;mainloop
gotodata;>mainloop
##########################
### decin digit processing
setdata;>decin.digit;decin.proc
setreg2;000000000
gotodataif;>decin.0
# + and - passed as +++ and ++- resp.
# otherwise, + and 1 would be the same.
setreg2;000000+0+
gotoifgreater;>decin.trit
## 1-9
romread1;>decin.base
setreg2;000000+0+
gotodataif;>decin.append
# base isn't 10
romread1;>decin.count
setreg2;000000000
gotodataif;>decin.makedec0
setreg2;00000000+
gotodataif;>decin.makedec1
gotodata;>decin.error
# on first digit
romread1;>decin.digit;decin.makedec0
gotodata;>decin.makedec
# on second digit, use first as sign
romread1;>decin.number;decin.makedec1
romread2;>decin.digit
multiply
setdata;>decin.number;decin.makedec
setreg1;000000+0+
setdata;>decin.base
gotodata;>mainloop
## 0
romread1;>decin.count;decin.0
setreg2;000000000
gotodataif;>mainloop
gotodata;>decin.append
## + and -
setreg2;000000++0;decin.trit
subtract
setdata;>decin.digit
romread1;>decin.base
setreg2;000000+0+
gotodataif;>decin.error
## all prepared, do the job
romread1;>decin.number;decin.append
romread2;>decin.base
multiply
romread2;>decin.digit
add
setdata;>decin.number
romread1;>decin.count
setreg2;00000000+
add
setdata;>decin.count
continue
;decin.error
;decin.cleanup
##########################
### decin key routines
## enter key
#>> change to use decin.cleanup & reset the new registers
romread1;>decin.pressflag;key.enter
setreg2;000000000
gotodataif;>decin.null.enter
romread1;>decin.number
dumpreg1
setreg1;000000000
setdata;>decin.number
setdata;>decin.pressflag
TTYwrite;:enter;decin.null.enter
romread1;>decin.reg1bak
romread2;>decin.reg2bak
gotodata;>mainloop
TTYwrite;:+;key.plus
setreg1;000000+++
gotodata;>decin.proc
TTYwrite;:-;key.minus
setreg1;000000++-
gotodata;>decin.proc
TTYwrite;:0;key.0
setreg1;000000000
gotodata;>decin.proc
TTYwrite;:1;key.1
setreg1;00000000+
gotodata;>decin.proc
TTYwrite;:2;key.2
setreg1;0000000+-
gotodata;>decin.proc
TTYwrite;:3;key.3
setreg1;0000000+0
gotodata;>decin.proc
TTYwrite;:4;key.4
setreg1;0000000++
gotodata;>decin.proc
TTYwrite;:5;key.5
setreg1;000000+--
gotodata;>decin.proc
TTYwrite;:6;key.6
setreg1;000000+-0
gotodata;>decin.proc
TTYwrite;:7;key.7
setreg1;000000+-+
gotodata;>decin.proc
TTYwrite;:8;key.8
setreg1;000000+0-
gotodata;>decin.proc
TTYwrite;:9;key.9
setreg1;000000+00
gotodata;>decin.proc