forked from mathewmariani/MARIE-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.mas
47 lines (39 loc) · 1001 Bytes
/
array.mas
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
ORG 0
Cond, LOAD COUNT / LOAD count into AC
SUBT ARRAY / SUBTRACT array[0] from AC
SKIPCOND 000 / Skipcond 000 if AC < 0
JUMP End / JUMP to End
Loop, LOAD COUNT / LOAD Count into AC
ADD ONE / ADD ONE to AC
STORE COUNT / STORE AC into COUNT
LOADI INDEX / LOAD MEM[index] into AC
OUTPUT / OUTPUT value at index
LOAD INDEX
ADD ONE
STORE INDEX
JUMP Cond / JUMP to Cond
End, LOAD START / LOAD start into AC
STORE INDEX / STORE AC into index
HALT / HALT process
INDEX, HEX 013 / Our current memory location
START, HEX 013 / The memory location of our first value (in hex)
ARRAY, DEC 5 / The first index of our array (used for size)
DEC 0 / index 0
DEC 2 / index 1
DEC 4 / index 2
DEC 8 / index 3
DEC 16 / index 4
/ variables
COUNT, DEC 0
/ constant values
ZERO, DEC 0
ONE, DEC 1
TWO, DEC 2
THREE, DEC 3
FOUR, DEC 4
FIVE, DEC 5
SIX, DEC 6
SEVEN, DEC 7
EIGHT, DEC 8
NINE, DEC 9
TEN, DEC 10