-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment 7.s
More file actions
58 lines (52 loc) · 977 Bytes
/
Assignment 7.s
File metadata and controls
58 lines (52 loc) · 977 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
AREA RESET, DATA, READONLY
EXPORT __VECTORS
__VECTORS
DCD 0X20001000
DCD Reset_Handler
plaintext DCB "LETS KILL A ZEBRA", 0;
caesarkey DCD 3;
substitutionkey DCB "QWERTYUIOPASDFGHJKLZXCVBNM"
ALIGN
AREA DATASPACE, DATA, READWRITE
ciphertext SPACE 100;
AREA MAIN, CODE, READONLY
ENTRY
EXPORT Reset_Handler
caesar_cipher PROC
;for uppercase text only
LDR R0, =plaintext;
LDR R1, =ciphertext;
LDR R3, =caesarkey;
LDR R3, [R3];
loop
LDRB R2, [R0], #1;
CMP R2, #0;
BEQ stop_caesar;
CMP R2, #0X20;
BEQ store;
ADD R2, R3;
CMP R2, #0X5A;
BGT modulate;
BLE store;
modulate
SUB R2, #26;
store
STRB R2, [R1], #1;
B loop;
stop_caesar
STRB R2, [R1], #1;
LDR R0, =ciphertext;
BX LR;
ENDP
substitution_cipher PROC
;AGAIN, ONLY WORKS WITH CAPITAL LETTERS
LDR R0, =plaintext;
LDR R1, =substitutionkey;
LDRB R2, [R0], #1;
SUB R2, #1;
ENDP
Reset_Handler
BL caesar_cipher;
stop
SWI 0X11;
END