-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_LoadMemory.asm
More file actions
300 lines (200 loc) · 5.06 KB
/
Copy pathTest_LoadMemory.asm
File metadata and controls
300 lines (200 loc) · 5.06 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
;Test for load data from memory
;Author Claudio "CP" La Rosa
;Public release: June 2026
.ORG 0
.INCLUDE serial.i
.DATA
str_head DC4.T " == Test for Data Size Transfer Instructions ==",0
str_mem DC4.T "Memory value : ",0
str_reg DC4.T "Register value : ",0
str_sizet DC4.T "Register after load TRYTE: ",0
str_sizes DC4.T "Register after load SHORT: ",0
str_sizew DC4.T "Register after load WORD : ",0
str_trypp DC4.T "******* Try with Stack functions (no registers) *******",0
str_sp DC4.T "Value of stack pointer: ",0
str_tryppr DC4.T "******* Try with Stack functions with explicit register *******",0
.CODE
;Disable all interrupts
DI
;----------------------
;Initialize Stack
ANYI R60,R0,#8000 ;R60 indirizzo stack
STSP R60
;---------------------------------------
ANYI R7,R0,#SERIAL_PORT_2
LEA R27,str_head
JSR println
;--- Fill memory ---
ANYI R20,R0,#-265720
ASHI R20,R20,#-12
ANYI R20,R20,#-265720
ANYI R22,R0,#19000 ;memory location
ST 0(R22),R20 ;store in memory at (R22)
;view the value
LEA R27,str_mem
JSR print
ANYI R15,R0,#24
;ANY R10,R0,R20
LD R10,0(R22)
JSR print_integer_ternary
JSR new_line
;--- Fill a register --------------
ANYI R8,R0,#210240 ; ++--00++--00
ASHI R8,R8,#-12
ANYI R8,R8,#210240 ; ++--00++--00
LEA R27,str_reg
JSR print
ANYI R15,R0,#24
ANY R10,R0,R8
JSR print_integer_ternary
JSR new_line
;---- Load from memory TRYTE
LEA R27,str_sizet
JSR print
ANY R9,R0,R8 ; in R9 the register value
LD.T R9,0(R22) ;Load from memory at (R22)
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
;---- Load from memory SHORT
LEA R27,str_sizes
JSR print
ANY R9,R0,R8 ; in R9 the register value
LD.S R9,0(R22) ;Load from memory at (R22)
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
;---- Load from memory WORD
LEA R27,str_sizew
JSR print
ANY R9,R0,R8 ; in R9 the register value
LD.W R9,0(R22) ;Load from memory at (R22)
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
; ********************************************************
; **************** Try with PUSH/POP *********************
; ********************************************************
LEA R27,str_trypp
JSR println
;--- Fill memory ---
ANYI R1,R0,#-265720
ASHI R1,R1,#-12
ANYI R1,R1,#-265720
PUSH R1
;view the value
LEA R27,str_mem
JSR print
ANYI R15,R0,#24
ANY R10,R0,R1
JSR print_integer_ternary
JSR new_line
;--- Fill a register --------------
ANYI R8,R0,#210240 ;
ASHI R8,R8,#-12
ANYI R8,R8,#210240 ;
LEA R27,str_reg
JSR print
ANYI R15,R0,#24
ANY R10,R0,R8
JSR print_integer_ternary
JSR new_line
;---- Load from memory TRYTE
LEA R27,str_sizet
JSR print
ANY R9,R0,R8 ; in R9 the register value
POP.T R9 ;Load from stack
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
;---- Load from memory SHORT
PUSH R1
LEA R27,str_sizes
JSR print
ANY R9,R0,R8 ; in R9 the register value
POP.S R9
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
;---- Load from memory WORD
PUSH R1
LEA R27,str_sizew
JSR print
ANY R9,R0,R8 ; in R9 the register value
POP.W R9
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
; ********************************************************
; **************** Try with PUSH/POPR *********************
; ********************************************************
ANYI R60,R0,#9800 ; new stack base
LEA R27,str_tryppr
JSR println
;--- Fill memory ---
ANYI R1,R0,#265720
ASHI R1,R1,#-12
ANYI R1,R1,#265720
PUSHR (R60),R1
;view the value
LEA R27,str_mem
JSR print
ANYI R15,R0,#24
ANY R10,R0,R1
JSR print_integer_ternary
JSR new_line
;--- Fill a register --------------
LEA R27,str_reg
JSR print
ANYI R15,R0,#24
ANY R10,R0,R8
JSR print_integer_ternary
JSR new_line
;---- Load from memory TRYTE
LEA R27,str_sizet
JSR print
ANY R9,R0,R8 ; in R9 the register value
POPR.T R9,(R60) ;Load from stack
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
;---- Load from memory SHORT
PUSHR (R60),R1
LEA R27,str_sizes
JSR print
ANY R9,R0,R8 ; in R9 the register value
POPR.S R9,(R60)
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
;---- Load from memory WORD
PUSHR (R60),R1
LEA R27,str_sizew
JSR print
ANY R9,R0,R8 ; in R9 the register value
POPR.W R9,(R60)
ANY R10,R0,R9
JSR print_integer_ternary
JSR new_line
HLT
;-------------------
; NEW LINE
;
; input: R7 Serial Port
;-------------------
new_line:
;PROLOGUE
PUSH R4
;Insert return value on the stack
PUSH R26
;new line
ANYI R4,R0,#10 ;<LF>
OUT 0(R7),R4
ANYI R4,R0,#13 ;<CR>
OUT 0(R7),R4
;EPILOGUE
POP R26
POP R4
JR R26
;------------------------------ END new_line
.INCLUDE COMMON/IO_fun.i