Skip to content

Commit 55b1d5e

Browse files
committed
clean folder
1 parent 8de71cd commit 55b1d5e

28 files changed

+2323
-0
lines changed

Base64/base64-decode.asm

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
;=================================================
2+
; Base64 Decode (v1.1)
3+
;=================================================
4+
5+
; +----------------+------+-------+-------+------+
6+
; | Base64-encoded | T | W | F | u | Input: 4 chars
7+
; +----------------+------+-------+-------+------+
8+
; | Index | 19 | 22 | 5 | 46 | Step1: Base64 Decode Table
9+
; +----------------+------+-------+-------+------+
10+
; | Bit pattern |010011|01|0110|0001|01|101110| Step2: Bits operations
11+
; +----------------+---------+---------+---------+
12+
; | ASCII | 77 | 97 | 110 |
13+
; +----------------+---------+---------+---------+
14+
; | Text content | M | a | n | Output: 3 chars
15+
; +----------------+---------+---------+---------+
16+
17+
;=================================================
18+
; Constants
19+
;=================================================
20+
21+
assert_zero EQU $00D0000C ; magical register
22+
23+
;=================================================
24+
; Entry Point
25+
;=================================================
26+
27+
Start:
28+
29+
lea String1,a1 ; decode 1st string
30+
lea Buffer1,a2 ;
31+
jsr Base64Decode ;
32+
33+
lea String2,a1 ; decode 2nd string
34+
lea Buffer2,a2 ;
35+
jsr Base64Decode ;
36+
37+
lea Buffer1,a0 ; check 1st string
38+
lea Precal1,a1 ;
39+
jsr SelfTest ;
40+
41+
lea Buffer2,a0 ; check 2nd string
42+
lea Precal2,a1 ;
43+
jsr SelfTest ;
44+
45+
stop #-1 ; stop execution
46+
47+
;=================================================
48+
; SelfTest SubRoutine
49+
; A0 = Calculated string
50+
; A1 = Precalculated string
51+
;=================================================
52+
53+
SelfTest:
54+
move.b (a0)+,d0 ; read calculated char
55+
beq .SelfTestExit ; exit if null-char
56+
sub.b (a1)+,d0 ; compare with precalculated char
57+
move.l d0,assert_zero ; raise error if D0 != 0
58+
bra SelfTest ; continue
59+
60+
.SelfTestExit:
61+
rts ; exit subroutine
62+
63+
;=================================================
64+
; Base64 Decode SubRoutine
65+
; A1 = String encoded in Base64
66+
; A2 = Buffer for decoded string
67+
;=================================================
68+
69+
Base64Decode:
70+
lea B64DecodeTbl-43,a0 ; base64 decode table
71+
clr.l d0 ; init registers
72+
clr.l d1 ;
73+
clr.l d2 ;
74+
75+
.Base64DecodeLoop:
76+
move.b (a1)+,d0 ; decode 1st char
77+
beq .Base64DecodeExit ; exit if null-char
78+
move.b (a1)+,d1 ; ( a << 2 ) | ( b >> 4 )
79+
move.b (a0,d0),d0 ;
80+
move.b (a0,d1),d1 ;
81+
move.b d1,d2 ;
82+
lsl.b #2,d0 ;
83+
lsr.b #4,d2 ;
84+
or.b d0,d2 ;
85+
move.b d2,(a2)+ ;
86+
move.b (a1)+,d0 ; decode 2nd char
87+
move.b (a0,d0),d0 ; ( b << 4 ) | ( c >> 2 )
88+
move.b d0,d2 ;
89+
lsl.b #4,d1 ;
90+
lsr.b #2,d2 ;
91+
or.b d1,d2 ;
92+
move.b d2,(a2)+ ;
93+
move.b (a1)+,d1 ; decode 3rd char
94+
move.b (a0,d1),d1 ; ( c << 6 ) | d
95+
lsl.b #6,d0 ;
96+
or.b d0,d1 ;
97+
move.b d1,(a2)+ ;
98+
bra .Base64DecodeLoop ; continue
99+
100+
.Base64DecodeExit:
101+
rts ; exit subroutine
102+
103+
;=================================================
104+
; Base64 Decode Table
105+
;=================================================
106+
107+
B64DecodeTbl:
108+
dc.b 62 ; +
109+
ds.b 3 ; unused
110+
dc.b 63 ; /
111+
dc.b 52,53,54,55,56,57,58,59,60,61 ; 0..9
112+
ds.b 7 ; unused
113+
dc.b 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 ; A..Z
114+
dc.b 15,16,17,18,19,20,21,22,23,24,25 ;
115+
ds.b 6 ; unused
116+
dc.b 26,27,28,29,30,31,32,33,34,35,36,37,38 ; a..z
117+
dc.b 39,40,41,42,43,44,45,46,47,48,49,50,51 ;
118+
119+
;=================================================
120+
; Data Section
121+
;=================================================
122+
123+
String1: dc.b 'QW1pZ2EgUnVsZXoh',0
124+
Buffer1: dc.b '____________',0
125+
Precal1: dc.b 'Amiga Rulez!',0
126+
127+
;=================================================
128+
129+
String2: dc.b 'QVNNIDY4SyBpcyBmdW4u',0
130+
Buffer2: dc.b '_______________',0
131+
Precal2: dc.b 'ASM 68K is fun.',0
132+
133+
;=================================================

Base64/base64-encode.asm

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
;=================================================
2+
; Base64 Encode (v1.3)
3+
;=================================================
4+
5+
; +----------------+---------+---------+---------+
6+
; | Text content | M | a | n | Input: 3 chars
7+
; +----------------+---------+---------+---------+
8+
; | ASCII | 77 | 97 | 110 |
9+
; +----------------+---------+---------+---------+
10+
; | Bit pattern |010011|01|0110|0001|01|101110| Step1: Bits operations
11+
; +----------------+------+-------+-------+------+
12+
; | Index | 19 | 22 | 5 | 46 | Step2: Base64 Encode Table
13+
; +----------------+------+-------+-------+------+
14+
; | Base64-encoded | T | W | F | u | Output: 4 chars
15+
; +----------------+------+-------+-------+------+
16+
17+
;=================================================
18+
; Constants
19+
;=================================================
20+
21+
assert_zero EQU $00D0000C ; magical register
22+
23+
;=================================================
24+
; Entry Point
25+
;=================================================
26+
27+
Start:
28+
29+
lea String1,a1 ; encode 1st string
30+
lea Buffer1,a2 ;
31+
jsr Base64Encode ;
32+
33+
lea String2,a1 ; encode 2nd string
34+
lea Buffer2,a2 ;
35+
jsr Base64Encode ;
36+
37+
lea Buffer1,a0 ; check 1st string
38+
lea Precal1,a1 ;
39+
jsr SelfTest ;
40+
41+
lea Buffer2,a0 ; check 2nd string
42+
lea Precal2,a1 ;
43+
jsr SelfTest ;
44+
45+
stop #-1 ; stop execution
46+
47+
;=================================================
48+
; SelfTest SubRoutine
49+
; A0 = Calculated string
50+
; A1 = Precalculated string
51+
;=================================================
52+
53+
SelfTest:
54+
move.b (a0)+,d0 ; read calculated char
55+
beq .SelfTestExit ; exit if null-char
56+
sub.b (a1)+,d0 ; compare with precalculated char
57+
move.l d0,assert_zero ; raise error if D0 != 0
58+
bra SelfTest ; continue
59+
60+
.SelfTestExit:
61+
rts
62+
63+
;=================================================
64+
; Base64 Encode SubRoutine
65+
; A1 = String to encode in Base64
66+
; A2 = Buffer for encoded string
67+
;=================================================
68+
69+
Base64Encode:
70+
lea B64EncodeTbl,a0 ; base64 encode table
71+
clr.l d0 ; init registers
72+
clr.l d1 ;
73+
clr.l d2 ;
74+
75+
.Base64EncodeLoop:
76+
move.b (a1)+,d0 ; encode 1st char
77+
beq .Base64EncodeExit ; exit if null char
78+
move.b d0,d1 ; ( a >> 2 )
79+
lsr.b #2,d1 ;
80+
move.b (a0,d1),(a2)+ ;
81+
move.b (a1)+,d1 ; encode 2nd char
82+
move.b d1,d2 ; ( ( a << 4 ) & %00111111 | ( b >> 4 )
83+
lsl.b #4,d0 ;
84+
andi.b #%00111111,d0 ;
85+
lsr.b #4,d2 ;
86+
or.b d0,d2 ;
87+
move.b (a0,d2),(a2)+ ;
88+
move.b (a1)+,d2 ; encode 3rd char
89+
move.b d2,d0 ; ( ( b << 2 ) & %00111111 ) | ( c >> 6 )
90+
lsl.b #2,d1 ;
91+
andi.b #%00111111,d1 ;
92+
lsr.b #6,d0 ;
93+
or.b d1,d0 ;
94+
move.b (a0,d0),(a2)+ ;
95+
andi.b #%00111111,d2 ; encode 4th char
96+
move.b (a0,d2),(a2)+ ; ( c & %00111111 )
97+
bra .Base64EncodeLoop ; continue
98+
99+
.Base64EncodeExit:
100+
rts ; exit subroutine
101+
102+
;=================================================
103+
; Base64 Encode Table
104+
;=================================================
105+
106+
B64EncodeTbl:
107+
dc.b 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
108+
dc.b 'abcdefghijklmnopqrstuvwxyz'
109+
dc.b '0123456789+/'
110+
111+
;=================================================
112+
; ASCII strings to encode in Base64
113+
;=================================================
114+
115+
String1: dc.b 'Amiga Rulez!',0
116+
Buffer1: dc.b '________________',0
117+
Precal1: dc.b 'QW1pZ2EgUnVsZXoh',0
118+
119+
;=================================================
120+
121+
String2: dc.b 'ASM 68K is fun.',0
122+
Buffer2: dc.b '____________________',0
123+
Precal2: dc.b 'QVNNIDY4SyBpcyBmdW4u',0
124+
125+
;=================================================

Ea-Modes/ea_mode_test_1.asm

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
;===========================
2+
; Motorola 68K - ASM test
3+
; EA Mode test 1
4+
;===========================
5+
6+
assert_zero EQU $00D0000C ; magical register
7+
8+
size = 64
9+
10+
;===========================
11+
12+
start:
13+
clr.l d0
14+
clr.l d1
15+
clr.l d2
16+
clr.l d3
17+
clr.l d6
18+
clr.l d7
19+
init:
20+
lea tbl,a5
21+
lea values,a1
22+
lea buffer,a2
23+
move.l #precalc,(0,a5)
24+
move.l #buffer,(4,a5)
25+
move.l #values,(8,a5)
26+
move.l #$FFFFFFFF,(12,a5)
27+
move.l #size-1,d7
28+
repeat:
29+
move.l d7,a3
30+
move.l (16,[8,a5],a3.w*4),(7,[4,a5],a3.w*4)
31+
move.l (7,[4,a5],a3.l*4),d3
32+
andi.b #$F0,(7,[4,a5],a3.l*4)
33+
not.l (7,[4,a5],a3.l*4)
34+
subi.b #10,(8,[4,a5],a3.l*4)
35+
move.b d3,(9,a2,a3.l*4)
36+
neg.b (9,a2,a3.l*4)
37+
jsr selftest
38+
dbf d7,repeat
39+
exit:
40+
stop #-1
41+
42+
selftest:
43+
move.l (7,[4,a5],a3.l*4),d2
44+
sub.l ([0,a5],a3.l*4),d2
45+
move.l d2,assert_zero
46+
beq noerror
47+
add.l #1,d6
48+
noerror:
49+
rts
50+
51+
;===========================
52+
53+
tbl:
54+
ds.l 4
55+
56+
;===========================
57+
58+
values:
59+
dc.b $99,$99,$99,$99,$99,$99,$99,$99 ; unused
60+
dc.b $99,$99,$99,$99,$99,$99,$99,$99 ; unused
61+
dc.b $18,$71,$02,$DB,$08,$DB,$73,$A2
62+
dc.b $03,$08,$D7,$7B,$60,$11,$1C,$A2
63+
dc.b $4C,$CC,$B9,$DC,$44,$B5,$59,$D9
64+
dc.b $7F,$61,$86,$37,$78,$3A,$F6,$5A
65+
dc.b $90,$ED,$89,$69,$49,$A7,$33,$8D
66+
dc.b $0C,$73,$4F,$D5,$A3,$FA,$26,$36
67+
dc.b $CC,$24,$1A,$6D,$82,$C9,$B5,$37
68+
dc.b $C9,$D3,$B1,$7F,$DF,$1E,$EB,$86
69+
dc.b $5F,$EE,$75,$3F,$4B,$90,$B3,$F9
70+
dc.b $89,$2A,$76,$9F,$C3,$C8,$A3,$98
71+
dc.b $0F,$5A,$A0,$24,$51,$CE,$82,$10
72+
dc.b $8D,$9D,$8C,$0E,$48,$66,$14,$58
73+
dc.b $E7,$2E,$7D,$07,$CC,$60,$B4,$7E
74+
dc.b $AB,$02,$D6,$A2,$3E,$0B,$3E,$E3
75+
dc.b $F3,$92,$20,$3F,$1C,$86,$D1,$11
76+
dc.b $59,$37,$29,$B8,$DD,$F8,$6C,$8B
77+
dc.b $89,$13,$BD,$46,$FE,$24,$7E,$96
78+
dc.b $E7,$D7,$81,$74,$7A,$34,$60,$62
79+
dc.b $9C,$0F,$89,$C0,$BF,$54,$6C,$51
80+
dc.b $DD,$75,$E8,$5E,$3E,$86,$45,$D1
81+
dc.b $49,$4A,$0F,$6F,$9B,$6E,$6A,$52
82+
dc.b $EC,$ED,$1F,$8D,$5D,$3E,$FF,$2D
83+
dc.b $BC,$EC,$EE,$4D,$62,$C6,$87,$63
84+
dc.b $14,$2A,$A7,$44,$B9,$F3,$1E,$64
85+
dc.b $49,$55,$BB,$49,$6B,$D6,$02,$AF
86+
dc.b $A5,$EA,$9B,$83,$39,$2C,$A5,$C9
87+
dc.b $E1,$5C,$E3,$F2,$F5,$EE,$BA,$14
88+
dc.b $45,$82,$C5,$EA,$11,$E3,$23,$FD
89+
dc.b $A7,$63,$18,$B2,$47,$CF,$1E,$AA
90+
dc.b $EB,$B8,$C5,$B3,$94,$7F,$4E,$BB
91+
dc.b $AF,$2F,$26,$81,$22,$4D,$2D,$7C
92+
dc.b $0E,$38,$ED,$83,$BC,$BC,$F5,$A9
93+
dc.b $88,$88,$88,$88,$88,$88,$88,$88 ; unused
94+
dc.b $88,$88,$88,$88,$88,$88,$88,$88 ; unused
95+
96+
buffer:
97+
dc.b $99,$99,$99,$99,$99,$99,$99 ; unused
98+
ds.b size*4
99+
dc.b $99,$99,$99,$99,$99,$99,$99,$99 ; unused
100+
101+
precalc:
102+
dc.b $EF,$84,$25,$24,$FF,$1A,$5E,$5D
103+
dc.b $FF,$ED,$85,$84,$9F,$E4,$5E,$5D
104+
dc.b $BF,$29,$24,$23,$BF,$40,$27,$26
105+
dc.b $8F,$94,$C9,$C8,$8F,$BB,$A6,$A5
106+
dc.b $6F,$08,$97,$96,$BF,$4E,$73,$72
107+
dc.b $FF,$82,$2B,$2A,$5F,$FB,$CA,$C9
108+
dc.b $3F,$D1,$93,$92,$7F,$2C,$C9,$C8
109+
dc.b $3F,$22,$81,$80,$2F,$D7,$7A,$79
110+
dc.b $AF,$07,$C1,$C0,$BF,$65,$07,$06
111+
dc.b $7F,$CB,$61,$60,$3F,$2D,$68,$67
112+
dc.b $FF,$9B,$DC,$DB,$AF,$27,$F0,$EF
113+
dc.b $7F,$58,$F2,$F1,$BF,$8F,$A8,$A7
114+
dc.b $1F,$C7,$F9,$F8,$3F,$95,$82,$81
115+
dc.b $5F,$F3,$5E,$5D,$CF,$EA,$1D,$1C
116+
dc.b $0F,$63,$C1,$C0,$EF,$6F,$EF,$EE
117+
dc.b $AF,$BE,$48,$47,$2F,$FD,$75,$74
118+
dc.b $7F,$E2,$BA,$B9,$0F,$D1,$6A,$69
119+
dc.b $1F,$1E,$8C,$8B,$8F,$C1,$9E,$9D
120+
dc.b $6F,$E6,$40,$3F,$4F,$A1,$AF,$AE
121+
dc.b $2F,$80,$A2,$A1,$CF,$6F,$2F,$2E
122+
dc.b $BF,$AB,$91,$90,$6F,$87,$AE,$AD
123+
dc.b $1F,$08,$73,$72,$AF,$B7,$D3,$D2
124+
dc.b $4F,$09,$B3,$B2,$9F,$2F,$9D,$9C
125+
dc.b $EF,$CB,$BC,$BB,$4F,$02,$9C,$9B
126+
dc.b $BF,$A0,$B7,$B6,$9F,$1F,$51,$50
127+
dc.b $5F,$0B,$7D,$7C,$CF,$C9,$37,$36
128+
dc.b $1F,$99,$0E,$0D,$0F,$07,$EC,$EB
129+
dc.b $BF,$73,$16,$15,$EF,$12,$03,$02
130+
dc.b $5F,$92,$4E,$4D,$BF,$26,$56,$55
131+
dc.b $1F,$3D,$4D,$4C,$6F,$76,$45,$44
132+
dc.b $5F,$C6,$7F,$7E,$DF,$A8,$84,$83
133+
dc.b $FF,$BD,$7D,$7C,$4F,$39,$57,$56
134+
135+
;===========================

0 commit comments

Comments
 (0)