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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/ input and store x
input
subt one
store x
/ input and store y
input
store y
/ input and store z
input
store z
/ calculate the exponent
jns exponent
/ calculate modulus
jump divide
/ bypass ac crunch
quit_divide, load result
output
halt
exponent, hex 0
load y
store y_count
_exponent_pass, load x
/ while (counter > 0)
skipcond 800
jumpi exponent
jns _exponent_multiply
/ y_count = result
load result
store y_count
/ x += 1
load x
subt one
store x
jump _exponent_pass
_exponent_multiply, hex 0
/ result = 0
load zero
store result
_exponent_multiplier, load y_count
/ while (y_count > 0)
skipcond 800
jumpi _exponent_multiply
/ result += y
load result
add y
store result
/ y_count += 1
load y_count
subt one
store y_count
jump _exponent_multiplier
divide, load dividend
/ dividend += _divide_temporary
add _divide_temporary
store dividend
/ result -= z
load result
subt z
store result
/ while (divide < 0)
skipcond 000
jump divide
/ dividend -= _divide_temporary
load dividend
subt _divide_temporary
store dividend
/ result += z
load result
add z
store result
jump quit_divide
/ constants
one, dec 1
zero, hex 0
/ mutable variables
x, hex 0
y, hex 0
y_count, hex 0
original_y, hex 0
z, hex 0
result, hex 0
dividend, hex 0
_divide_temporary, dec 1
|