L1lGh0sT
- 3
- 0
Homework Statement
I'm currently learning the little man computer and Currently I'm working on two programs. On one of them, I have the code to find the minimum value in an array, however I have to modify that code in order to find the maximum value. What would I have to change? And for the other program; that's supposed to multiply two integers. What would I need to change to make it work? Please advise.
Homework Equations
Find Min Code (Need to modify this code in order to find the maximum int)
BRA START
ARRAY0 DAT 5
DAT 4
DAT 3
DAT 7
DAT 5
DAT 2
DAT 1
DAT 7
ARRAYINDEX DAT 1
LENGTH DAT 8
MIN DAT 0
ONE DAT 1
LOADINST DAT 501
START LDA ARRAY0
STA MIN
LOOP LDA LOADINST
ADD ARRAYINDEX
STA LOADNEXT
LDA ARRAYINDEX
ADD ONE
STA ARRAYINDEX
LOADNEXT DAT 0
SUB MIN
BRP KEEPMIN
ADD MIN
STA MIN
KEEPMIN LDA LENGTH
SUB ARRAYINDEX
BRZ DONE
BRA LOOP
DONE LDA MIN
OUT
HLT
The Attempt at a Solution
//Need to fix this code to make it work.
LDA MULTIPLIC
BRZ DONE
LOOP LDA MULTIPLIER
BRZ DONE
SUB INCREMENT
BRZ DONE
LDA TOTAL
ADD MULTIPLIC
STA TOTAL
LDA INCREMENT
ADD ONE
STA INCREMENT
BRA LOOP
DONE LDA TOTAL
OUT TOTAL
HLT
INCREMENT DAT 0
ONE DAT 1
TOTAL DAT 0
MULTIPLIER DAT 5
MULTIPLIC DAT 3