-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q1.ASM
80 lines (66 loc) · 1.15 KB
/
Q1.ASM
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
ADDITION :
AREA PROGRAM2,CODE,READONLY
ENTRY
LDR R1,VALUE1
LDR R2,VALUE2
ADD R3,R2,R1
AREA PROGRAM2,DATA,READONLY
VALUE1 DCD &00000007
VALUE2 DCD &00000002
END
SUBTRACTION :
AREA PROGRAM2,CODE,READONLY
ENTRY
LDR R1,VALUE1
LDR R2,VALUE2
SUB R3,R2,R1
AREA PROGRAM2,DATA,READONLY
VALUE1 DCD &00000002
VALUE2 DCD &00000007
END
ii) Indirect addressing mode=2
ADDITION :
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R1,VALUE1
LDR R2,[R1]
LDR R3,VALUE2
LDR R4,[R3]
ADD R6,R4,R2
AREA PROGRAM,DATA,READONLY
VALUE1 DCD &00000500
VALUE2 DCD &00000800
END
SUBTRACTION :
AREA PROGRAM,CODE,READONLY
ENTRY
LDR R1,VALUE1
LDR R2,[R1]
LDR R3,VALUE2
LDR R4,[R3]
SUB R5,R4,R2
AREA PROGRAM,DATA,READONLY
VALUE1 DCD &00000500
VALUE2 DCD &00000800
END
iii) Barrel shifter=4
ADDITION USING LSL, LSR, ROR, ASR :
AREA PROGRAM2,CODE,READONLY
ENTRY
LDR R1,VALUE1
ADD R3,R1,R1,LSL #0X01
ADD R4,R1,R1,LSR #0X01
ADD R5,R1,R1,ROR #0X01
ADD R6,R1,R1,ASR #0X01
AREA PROGRAM2,DATA,READONLY
VALUE1 DCD &00000004
END
Subtraction using LSL
AREA Program,CODE,READONLY
ENTRY
LDR R1,val1
SUBS R2,R1,R1,LSL #1
AREA PROGRAM,DATA,READONLY
val1 DCD &00000002
END