-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl02_t02.s
44 lines (41 loc) · 982 Bytes
/
l02_t02.s
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
/*
-------------------------------------------------------
l02_t02.s
Assign to and add contents of registers.
-------------------------------------------------------
Author: David Brown
ID: 999999999
Email: dbrown@wlu.ca
Date: 2020-12-13
-------------------------------------------------------
*/
.org 0x1000 // Start at memory location 1000
.text // Code section
.global _start
_start:
// Copy data from memory to registers
LDR R3, =First
LDR R0, [R3]
LDR R3, =Second
LDR R1, [R3]
// Perform arithmetic and store results in memory
ADD R2, R0, R1
LDR R3, =Total
STR R2, [R3]//add brackets
SUB R2, R0, R1 // Subtract Second from First
LDR R3, =Diff//spelling error
STR R2, [R3]//add brackets.
// End program
_stop:
B _stop
.data // Initialized data section
First:
.word 4
Second:
.word 8
.bss // Uninitialized data section
Total:
.space 4 // Set aside 4 bytes for total
Diff:
.space 2 // Set aside 4 bytes for difference
.end