2

I have a program here that creates an array of 10 integers and asks the user to create the limit for the numbers being evaluated. For example, inputting a 7 will evaluate numbers 1-7 in the array. Due to my indexing methods, I start at 1, not 0. Of the numbers selected, the maximum number is to be stored and printed in an output. Everything works; however, I cannot run the program multiple times. I must reset the simulator manually each time to get an accurate result since only the AC clears when I add the command. I was wondering if there was any command that wiped the registers entirely without using the drop down menu in the MARIE jar? Here is my code:

/Begin at line 100.
org 0100

/clear AC of previous runs.
clear

/user input.
input

/Subtract 1 due to indexing method.
subt one

/add location of first
/value to input ro find limit.        
add ctr

/store into limit variable n.
store n

/load first value @ location ctr.
loadi ctr

/first value becomes largest for now.
store large

/subtract ctr to begin loop @ beginning of index
load ctr
subt one
store ctr

/loop while ctr < n
/Increment ctr.
loop,   load ctr 
add one
store ctr

/compare value @ ctr
/to current largest value.
loadi ctr
subt large

/stores value @ ctr
/if greater than large.
skipcond 800
skipcond 000
jump store

/Post test
/When ctr reaches n,
/loop breaks to Stop.
test,   load n
subt ctr
skipcond 400
jump loop

jump Stop

/stores variable @ address ctr
/Reached if variable > large.
store,  loadi ctr
store large
jump test

/Reached when ctr == n.
/Outputs large and halts.
Stop,   load large
output

halt

/Variables.
/ctr begins @ location of 
/first variable in array.
ctr,   hex 122
one,   hex 1
n,     hex 0
next,  hex 0
large, hex 0

/Array.
hex 1
hex 3
hex 2
hex 5
hex 6
hex 4
hex 8
hex 0
hex 9
hex 8  

Thank you!

  • Also, I wasn't quite sure where to ask this. My MARIE simulator is running on a jar, so I asked in the java section, but if I'm wrong just let me know. Thanks again – Paul Shumaker Apr 06 '16 at 16:19

1 Answers1

1

Ive not fully read your code but I encountered a similar problem and this is how I found your post. Ive just worked out how to clear the registers Once youve cleared the AC simply store the cleared AC to the variables

Clear Store n Store next Store large

This should assign the ac value which is 0 to your variables Sorry if this wasn't your problem but hope I could help

  • thanks for this info. I have been trying to fix this problem, and I was missing storing each variable after the clear command. – Kakarotto Sep 15 '21 at 15:19