1 |
dpavlin |
2 |
(Sorry, this is still in Swedish.) |
2 |
|
|
|
3 |
|
|
Ide: |
4 |
|
|
|
5 |
|
|
# Kommentar. Tomma rader ignoreras också. |
6 |
|
|
|
7 |
|
|
oaddr orig |
8 |
|
|
lnamn label |
9 |
|
|
anamn_eller_värde assemblera värdet "namn_eller_värde" |
10 |
|
|
s"string" ??? |
11 |
|
|
dnev1 nev2 assemblera värdet "nev1 - nev2 - x" där |
12 |
|
|
x = 1 om nev2 < nev1, annars x = 0 |
13 |
|
|
|
14 |
|
|
En vanlig fil kan t ex börja med: |
15 |
|
|
|
16 |
|
|
# PC |
17 |
|
|
|
18 |
|
|
o0 |
19 |
|
|
lpc |
20 |
|
|
amain |
21 |
|
|
|
22 |
|
|
# MIPS registers |
23 |
|
|
|
24 |
|
|
la0 |
25 |
|
|
a0 |
26 |
|
|
la1 |
27 |
|
|
a0 |
28 |
|
|
la2 |
29 |
|
|
a0 |
30 |
|
|
la3 |
31 |
|
|
a0 |
32 |
|
|
lv0 |
33 |
|
|
a0 |
34 |
|
|
|
35 |
|
|
|
36 |
|
|
# Function: main |
37 |
|
|
|
38 |
|
|
lmain |
39 |
|
|
ar0 |
40 |
|
|
ar0 |
41 |
|
|
ar0 |
42 |
|
|
osv... |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
x := 0 Clear contents of x CLEAR x |
47 |
|
|
Ax |
48 |
|
|
Ax |
49 |
|
|
Ax |
50 |
|
|
|
51 |
|
|
x2 := x1 Copy value in x1 to x2 MOVE x1 TO x2 |
52 |
|
|
Ax2 |
53 |
|
|
Ax2 |
54 |
|
|
Ax2 ; clear x2 |
55 |
|
|
Ascratch |
56 |
|
|
Ascratch |
57 |
|
|
Ax1 |
58 |
|
|
Ascratch |
59 |
|
|
Ascratch |
60 |
|
|
Ax2 |
61 |
|
|
Ascratch |
62 |
|
|
|
63 |
|
|
pc := label JMP label |
64 |
|
|
Ascratch |
65 |
|
|
Ascratch |
66 |
|
|
Ascratch |
67 |
|
|
Dl? label |
68 |
|
|
Ll? |
69 |
|
|
Apc |
70 |
|
|
|
71 |
|
|
if acc==0 then pc := label JZ label |
72 |
|
|
Azero |
73 |
|
|
Dlabel l? |
74 |
|
|
Azero |
75 |
|
|
Azero |
76 |
|
|
Ll? |
77 |
|
|
Apc |
78 |
|
|
|
79 |
|
|
if x==0 then pc := label JRZ x, label |
80 |
|
|
Azero |
81 |
|
|
Azero |
82 |
|
|
Azero |
83 |
|
|
Ax |
84 |
|
|
Azero |
85 |
|
|
Dlabel l? |
86 |
|
|
Azero |
87 |
|
|
Azero |
88 |
|
|
Ll? |
89 |
|
|
Apc |
90 |
|
|
|
91 |
|
|
x2 -= x1 SUB x1 FROM x2 |
92 |
|
|
Ascratch |
93 |
|
|
Ascratch |
94 |
|
|
Ascratch |
95 |
|
|
Ax1 |
96 |
|
|
Ax2 |
97 |
|
|
Ascratch |
98 |
|
|
Ascratch |
99 |
|
|
Ascratch ; maybe not neccessary? |
100 |
|
|
|
101 |
|
|
x2 += x1 ADD x1 TO x2 |
102 |
|
|
Ascratch2 |
103 |
|
|
Ascratch2 |
104 |
|
|
Ascratch2 |
105 |
|
|
Ax1 |
106 |
|
|
Ascratch2 ; scratch2 = -x1 |
107 |
|
|
Ascratch |
108 |
|
|
Ascratch |
109 |
|
|
Ascratch |
110 |
|
|
Ascratch2 |
111 |
|
|
Ax2 ; x2 = x2 - (-x1) |
112 |
|
|
Ascratch |
113 |
|
|
Ascratch |
114 |
|
|
Ascratch ; maybe not neccessary? |
115 |
|
|
|
116 |
|
|
*a = data STORE data AT a |
117 |
|
|
Al1 |
118 |
|
|
Al1 |
119 |
|
|
Al1 ; clear l1 |
120 |
|
|
Ascratch |
121 |
|
|
Ascratch |
122 |
|
|
Aa |
123 |
|
|
Ascratch |
124 |
|
|
Ascratch |
125 |
|
|
Al1 ; word at l1 = a |
126 |
|
|
Ascratch |
127 |
|
|
|
128 |
|
|
Al2 |
129 |
|
|
Al2 |
130 |
|
|
Al2 ; clear l2 |
131 |
|
|
Ascratch |
132 |
|
|
Ascratch |
133 |
|
|
Aa |
134 |
|
|
Ascratch |
135 |
|
|
Ascratch |
136 |
|
|
Al2 ; word at l2 = a |
137 |
|
|
Ascratch |
138 |
|
|
|
139 |
|
|
Al3 |
140 |
|
|
Al3 |
141 |
|
|
Al3 ; clear l3 |
142 |
|
|
Ascratch |
143 |
|
|
Ascratch |
144 |
|
|
Aa |
145 |
|
|
Ascratch |
146 |
|
|
Ascratch |
147 |
|
|
Al3 ; word at l3 = a |
148 |
|
|
Ascratch |
149 |
|
|
|
150 |
|
|
Al4 |
151 |
|
|
Al4 |
152 |
|
|
Al4 ; clear l4 |
153 |
|
|
Ascratch |
154 |
|
|
Ascratch |
155 |
|
|
Aa |
156 |
|
|
Ascratch |
157 |
|
|
Ascratch |
158 |
|
|
Al4 ; word at l4 = a |
159 |
|
|
Ascratch |
160 |
|
|
|
161 |
|
|
|
162 |
|
|
Ll1 |
163 |
|
|
A0 ; this will be overwritten with 'a' |
164 |
|
|
Ll2 |
165 |
|
|
A0 ; this will be overwritten with 'a' |
166 |
|
|
Ll3 |
167 |
|
|
A0 ; this will be overwritten with 'a' |
168 |
|
|
|
169 |
|
|
Ascratch |
170 |
|
|
Ascratch |
171 |
|
|
Adata |
172 |
|
|
Ascratch |
173 |
|
|
Ascratch |
174 |
|
|
|
175 |
|
|
Ll4 |
176 |
|
|
A0 ; this will be overwritten with 'a' |
177 |
|
|
|
178 |
|
|
Ascratch |
179 |
|
|
|
180 |
|
|
reg = *a LOAD reg FROM ADDRESS a |
181 |
|
|
Al1 |
182 |
|
|
Al1 |
183 |
|
|
Al1 ; clear contents of l1 |
184 |
|
|
Ascratch |
185 |
|
|
Ascratch |
186 |
|
|
Aa |
187 |
|
|
Ascratch |
188 |
|
|
Ascratch |
189 |
|
|
Al1 ; word at l1 is now 'a' |
190 |
|
|
Ascratch |
191 |
|
|
|
192 |
|
|
Areg |
193 |
|
|
Areg |
194 |
|
|
Areg ; clear reg |
195 |
|
|
Ascratch |
196 |
|
|
Ascratch |
197 |
|
|
Ll1 |
198 |
|
|
A0 ; this will be overwritten with 'a' |
199 |
|
|
Ascratch |
200 |
|
|
Ascratch |
201 |
|
|
Areg |
202 |
|
|
Ascratch |
203 |
|
|
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
----------------------------------------------------------------- |
210 |
|
|
Översättning av MIPS-instruktioner till RSSB: |
211 |
|
|
|
212 |
|
|
MIPS: RSSB: |
213 |
|
|
|
214 |
|
|
b label JMP label |
215 |
|
|
move r1, r2 MOVE |
216 |
|
|
load word LOAD |
217 |
|
|
store word STORE |
218 |
|
|
add r1,r2 ADD |
219 |
|
|
sub r1,r2 SUB |
220 |
|
|
|
221 |
|
|
|
222 |
|
|
Halvjobbiga: |
223 |
|
|
de som kräver indirekta adresser osv |
224 |
|
|
|
225 |
|
|
|
226 |
|
|
Jobbiga: |
227 |
|
|
mul |
228 |
|
|
and |
229 |
|
|
or |
230 |
|
|
not (?) |
231 |
|
|
xor (?) |
232 |
|
|
comparision < > == |