-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloader.asm
79 lines (71 loc) · 784 Bytes
/
loader.asm
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
. $a1 1
. $a2 1
. $dividend 1
;. $divisor 1
;. $quotient 1
. $seed 1
@init
lda 5896
sta $seed
ret
@swopab
sta $a1
stb $a2
lma $a2
lmb $a1
ret
@cpar
stb $a1
ldb 0
sub
lmb $a1
ret
@rnd
lda 75
lmb $seed
mul
; push
; pop
ldb 74
add
; push
; pop
ldb 65536
call @mod
sto $seed
; push
; pop
ldb 655
div
;out 2
ret
@mod
sta $dividend
;stb $divisor
div
mul
call @swopab
lma $dividend
sub
ret
@gcd
test z
jmpt :done_gcd
call @swopab
test z
jmpt :done_gcd
;:loop_gcd
test gt
jmpt :sub_gcd
call @swopab
:sub_gcd
sub
; push
; pop
test eq
;jmpf :loop_gcd
jmp @gcd
ldb 0
:done_gcd
add
ret