-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassembler_program.asm
More file actions
140 lines (136 loc) · 1.93 KB
/
Copy pathassembler_program.asm
File metadata and controls
140 lines (136 loc) · 1.93 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
asect 0xf1
IOReg: # Gives the address 0xf1 the symbolic name IOReg
asect 0xf0
stack: # Gives the address 0xf0 the symbolic name stack
asect 0x00
start:
ldi r0,stack
stsp r0 # Sets the initial value of SP to 0xf0
read:
ldi r0, IOReg # Load the address of the input and display in r0
clr r1 #clear registers
clr r2
clr r3
do # Begin the keyboard read loop
ld r0,r1 # Load r1 from data memory, which includes
# the I/O address space
tst r1
until ne # Drop out of the loop when r1 is not zero
st r0, r2 #set ready to 0
inc r0
ld r0, r1 # type
inc r0
ld r0, r2 # x
inc r0
ld r0, r3 # y
inc r0
if
tst r1
is eq
then
ld r0, r1 # size
dec r0
dec r0
dec r0
while
tst r1
stays ne # type = 0
st r0, r2
inc r0
st r0, r3
inc r0
st r0, r1
inc r2
dec r1
dec r0
dec r0
wend
dec r0
ldi r1, 1
st r0, r1 #set ready to 1
br read # Go back to the start of the read loop
fi
dec r1
if
tst r1
is eq
then
ld r0, r1 # size
dec r0
dec r0
dec r0
while
tst r1
stays ne # type = 3
st r0, r2
inc r0
st r0, r3
inc r0
st r0, r1
inc r3
dec r1
dec r0
dec r0
wend
dec r0
ldi r1, 1
st r0, r1 #set ready to 1
br read # Go back to the start of the read loop
fi
dec r1
if
tst r1
is eq
then
ld r0, r1 # size
dec r0
dec r0
dec r0
while
tst r1
stays ne # type = 3
st r0, r2
inc r0
st r0, r3
inc r0
st r0, r1
inc r2
inc r3
dec r1
dec r0
dec r0
wend
dec r0
ldi r1, 1
st r0, r1 #set ready to 1
br read # Go back to the start of the read loop
fi
dec r1
if
tst r1
is eq
then
ld r0, r1 # size
dec r0
dec r0
dec r0
while
tst r1
stays ne # type = 3
st r0, r2
inc r0
st r0, r3
inc r0
st r0, r1
inc r2
dec r3
dec r1
dec r0
dec r0
wend
dec r0
ldi r1, 1
st r0, r1 #set ready to 1
br read # Go back to the start of the read loop
fi
end