-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase64.pseu
65 lines (58 loc) · 907 Bytes
/
base64.pseu
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
//Memory-Efficient 4-Register Base64 algorithm by Lucas Lux
#DEFINE LENGTH = ... //string.size();
#DEFINE DATA = ... //*string;
i = 0
rstvar:
x = 0x3F //11111100
temp = 0
buf = 0
memacc = 0 //aka. Accumulator
SP = ... //aka. Stack Pointer
loop:
memacc = i - LENGTH
jz memacc, return
memacc = DATA + i
memacc = *memacc
memacc = memacc & x
memacc = memacc >> temp
memacc = buf | memacc
buf = afterpush
jp push
afterpush:
temp = x
x = ~x
memacc = DATA + i
memacc = *memacc
buf = memacc & x
x = x << temp
buf = buf << temp
temp = x
x = x nand 0x3F
i++
memacc = buf
buf = rstvar
jz x, push
x << temp
jp loop
push:
temp = memacc - 26
jl temp, isupper
temp = temp - 26
jl temp, islower
temp = temp - 10
jl temp, isnum
jz temp, isplus
memacc = 66
isplus:
memacc = memacc - 19
jp endpush
isnum:
memacc = memacc - 75
islower:
memacc = memacc + 6
isupper:
memacc = memacc + 65
endpush:
*SP = memacc
SP++
jp buf