aboutsummaryrefslogtreecommitdiff
path: root/tests/stack_machine_load_store/instructions.s.tcl
blob: 4d6da2aa228f72bd99cb0e3efeff5ca0a705766c (plain)
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
#!/usr/bin/env tclsh

source tclasm.tcl

### set stack to 0, store 4 numbers (h2B, h3B, h4B and h5B) at addresses
### h000002, h000012, h000022 and h000032 and load them back to stack (only 2
### will really get written to stack's memory, other 2 will remain in r0 and
### r1). Then, write them to h000008, h000018, h000028 and h000038.
### At the and use operand-addressing to load back value h3B from h000018
### (expressed as h000017 in im + h000001 in operand) and store it to h1FFFE2
### (expressed as h1FFFC0 in im + h000022 in operand).

### we're using small (in absolute) numbers and addresses for simplicity

## set up stack
_set_sp 0

## get number h2B into r1, and store it - repeat for other 3 numbers;
_const h2B
_store h02

_const h3B
_store h12

_const h2A
_store h22

_const h3A
_store h32

## get numbers back on stack
_load h02
_load h12
_load h22
_load h32

## store copies to new locations
_store h38
_store h28
_store h18
_store h08

## prepare operand for later store operation
_const h22

## use operand addressing to load back value from h000018
_const h01
_load+ h17

## use operand addressing to trove value to h1FFFE2 = h1FFFC0 + h000022
# immediate value gets sign-extended here!
_store+ h40

## finish test
halt