-
Notifications
You must be signed in to change notification settings - Fork 0
/
PROGRAM1.DNKMMS
69 lines (61 loc) · 903 Bytes
/
PROGRAM1.DNKMMS
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
SMA 31
MOVA $ma
SLL $acc
SLL $acc
SLL $acc
MOVR $ma
SMA 7
ADD $ma # calculates 255
MOVR $r12 # $r2 = $acc(255)
SLR $acc # $acc >> 1 = 127
MOVR $ma # $ma = 127
MOVR $r11 # $r11 = 127
SW $r12 # min = 255 @ addr 127
ADD $one # $acc=$acc+1 = 128
MOVR $r4 # $r4=128 = j
ADD $one # $acc=$acc+1 = 129
MOVR $r5 # $r5 = 129 = k
SMA 15 #
ADD $ma # $acc = $acc + $ma = 147
SMA 4
ADD $ma
MOVR $r13 # $r13 = 148
#Sets up loops indices and temporary min
STBR 3 # branches will evaluate as >
loop1:
MOVA $r4
MOVR $ma
LW $r0 # $r0 = ram[j]
ADD $one
MOVR $r5 #k = j+1
loop2:
MOVR $ma
LW $r1 # $r1 = ram[k]
MNABS $r1, $r0
ADD $one
MOVR $r5
MOVA $r8
MOVR $ma
MOVA $r12
CMP $ma, $acc
STBR 6
BR loopend
MOVA $ma
MOVR $r12
loopend:
MOVA $r13
CMP $acc, $r5
STBR 3
MOVA $r5
BR loop2
MOVA $r4
ADD $one
MOVR $r4
MOVA $r13
STBR 3
CMP $acc, $r4
BR loop1
MOVA $r11
MOVR $ma
SW $r12
HALT