-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwap.S
More file actions
39 lines (16 loc) · 704 Bytes
/
Copy pathSwap.S
File metadata and controls
39 lines (16 loc) · 704 Bytes
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
.data
A: .word 0x1A2A3A4A // 2190
B: .word 0x1B2B3B4B // 2194
.text
# Store string variables here.
.globl main # make the main symbol globally visible.
main:
# instructions to swap the content of A and B
la a0,A // load the address of A to register a0
la a1,B // load the address of B to register a1
lw t0,0(a0) // load the word at a0 to t0 register
lw t1,0(a1) // load the word at a1 to t1 register
sw t1,0(a0) // save the word at a0 (A) in t1 where the B was there before
sw t0,0(a1) // save the word at a1 (B) in t0 where the A was there before
ret
.end