-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaffine_cipher.s
More file actions
68 lines (53 loc) · 1.36 KB
/
Copy pathaffine_cipher.s
File metadata and controls
68 lines (53 loc) · 1.36 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
// Dedicated to Shree DR.MDD
.data
inverses: .byte 0, 1, 0, 9, 0, 21, 0, 15, 0, 3, 0, 19, 0, 0, 0, 7, 0, 23, 0, 11, 0, 5, 0, 17, 0, 25
.text
.globl encode
.globl decode
encode:
adrp x14, inverses
add x14, x14, :lo12:inverses
ldrb w11, [x14, x2]
cbz w11, finish
mov w11, w2
mov w12, w3
mov x2, #5
b cipher_loop
decode:
adrp x14, inverses
add x14, x14, :lo12:inverses
ldrb w11, [x14, x2]
cbz w11, finish
sub w12, w3, #4082
mneg w12, w12, w11
mov x2, #-1
b cipher_loop
finish:
strb wzr, [x0]
ret
cipher_loop:
mov x13, x2
mov w8, #' '
mov w9, #26
input_read:
ldrb w5, [x1], #1
cbz w5, finish
sub w10, w5, #'0'
cmp w10, #10
blo .process_char
orr w10, w5, #32
sub w10, w10, #'a'
cmp w10, w9
bhs input_read
madd w10, w11, w10, w12
udiv w15, w10, w9
msub w5, w15, w9, w10
add w5, w5, #'a'
.process_char:
cbnz x13, .store_char
strb w8, [x0], #1
mov x13, x2
.store_char:
strb w5, [x0], #1
sub x13, x13, 1
b input_read