-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSets.s
More file actions
107 lines (93 loc) · 3.25 KB
/
Sets.s
File metadata and controls
107 lines (93 loc) · 3.25 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
AREA Sets, CODE, READONLY
IMPORT main
EXPORT start
;This code belongs to Hannah Keating, JF TCD student
start
MOV R0, #0 ; int cSize =0;
LDR R2, =ASize ; aSize = address of aSize in memory;
LDR R3, =BSize ; bSize = address of bSize in memory;
LDR R2, [R2] ; aSize = memory.Byte[aSize]
LDR R3, [R3] ; bSize = memory.Byte[bSize]
LDR R4, =AElems ; aStartAddress= start of set A
LDR R5, =BElems ; bStartAddress= start of set B
LDR R6, =CElems ; cAddress = address of CElems in memory;
MOV R7, R4 ; tempAdrA = aStartAdress;
MOV R9, #0 ; int countA = 0;
whLoopA
CMP R9, R2 ; while( countA != aSize)
BEQ endwhLoopA ; {
LDR R11, [R7] ; elemA = memory.Byte[tempAdrA];
MOV R8, R5 ; tempAdrB = bStartAdress;
MOV R10,#0 ; int countB = 0;
MOV R1, #1 ; boolean notEqual = true;
whCompareB
CMP R10, R3 ; while( countB != bSize
BEQ endWhCompareB ; &&
CMP R1, #0 ; notEqual)
BEQ endWhCompareB ; {
LDR R12, [R8] ; elemB = memory.Byte[tempAdrB];
CMP R11, R12 ; if( elemA == elemB)
BNE notEqual ; {
MOV R1, #0 ; boolean notEqual = false;
notEqual ; }
ADD R8, R8,#4 ; tempAdrB = tempAdrB +4;;
ADD R10, R10, #1 ; countB++;
B whCompareB ; }
;This code belongs to Hannah Keating, JF TCD student
endWhCompareB ;
CMP R1, #1 ; If ( notEqual )
BNE notUnique ; {
STR R11, [R6] ; memory.Byte[cAddress ] = elemA;
ADD R6, R6, #4; ; cAddress = cAddress + 4;
ADD R0, R0, #1 ; cSize++;
notUnique ; }
ADD R7, R7, #4; ; aAddress = aAddress + 4;
ADD R9, R9, #1 ; countA++;
B whLoopA ; }
endwhLoopA
MOV R8, R5 ; tempAdrB = bStartAdress;
MOV R10, #0 ; int countB = 0;
whLoopB
CMP R10, R3 ; while( countB != bSize)
BEQ endwhLoopB ; {
LDR R12, [R8] ; elemB = memory.Byte[tempAdrB];
MOV R7, R4 ; tempAdrA = aStartAdress;
MOV R9,#0 ; int countA = 0;
MOV R1, #1 ; boolean notEqual = true;
whCompareA ;
CMP R9, R2 ; while( countA != aSize
BEQ endWhCompareA ; &&
CMP R1, #1 ; notEqual)
BNE endWhCompareA ; {
LDR R11, [R7] ; elemA = memory.Byte[tempAdrA];
CMP R11, R12 ; if( elemA == elemB)
BNE notEqualB ; {
MOV R1, #0 ; boolean notEqual = false;
notEqualB ; }
ADD R7, R7,#4 ; tempAdrA = tempAdrA +4;;
ADD R9, R9, #1 ; countA++;
B whCompareA ; }
endWhCompareA ;
CMP R1, #1 ; If ( notEqual )
BNE notUniqueB ; {
STR R12, [R6] ; memory.Byte[cAddress ] = elemB;
ADD R6, R6, #4; ; cAddress = cAddress + 4;
ADD R0, R0, #1 ; cSize++;
notUniqueB ; }
ADD R8, R8, #4; ; bAddress = bAddress + 4;
ADD R10, R10, #1 ; countB++;
B whLoopB ; }
endwhLoopB
;This code belongs to Hannah Keating, JF TCD student
LDR R1, =CSize ; cSizeAdr = adress of CSize in memory
STR R0, [R1] ; Memory.Bye[cSizeAdr ] =cSize ;
stop B stop
;This code belongs to Hannah Keating, JF TCD student
AREA TestData, DATA, READWRITE
ASize DCD 5 ; Number of elements in A
AElems DCD 45,75,90,700,6 ; Elements of B
BSize DCD 5 ; Number of elements in B
BElems DCD 700,75,100,3,78 ; Elements of B
CSize DCD 0 ; Number of elements in C
CElems SPACE 56 ; Elements of C
END