Menu

[Solved]Fyi Ve Completed 21 22 M Trouble 23 Code Right Jns Listinput Halt Listinput Dec 0 Loop Inp Q37069697

2.1 Inputting a list of numbers (15 marks) The first step is to input a set of numbers (number-by-number, using the Input ins

FYI: I’ve completed 2.1 and 2.2, I’m having trouble on 2.3. Thecode I have right now is:

JnS ListInput
Halt
ListInput, dec 0
loop, input / loop for input using subroutine
   skipcond 400 / skip if input is 0
   jump keep / if not 0 jump to keep
   jump endlist / if input is 0, jump to endlist
  
keep, storeI x / store indirect x
   load x
add one
store x
   load inputlist / load the input list, add one andstore
add one
store inputlist
   jump loop
  
endlist, load inputlist / load the inputlist
output / output

halt / end program

JumpI ListInput

/ define x, one and inputlist
x, hex 50
one, dec 1
inputlist, dec 0

2.1 Inputting a list of numbers (15 marks) The first step is to input a set of numbers (number-by-number, using the Input instruction). You can assume that this will be a set of positive integers and that the last number given will be a zero. This means you can keep reading numbers until you receive a zero. Setup code in MARIE which reads a set of positive integers and stores these as an array (contiguous block of memory) Do not include the 0 in the array; as you accept numbers you should keep track of the size and store this in a variable once all the reading is complete. Print the size of the array using the Output instruction to help you test that your program is correct. 2.2 List input subroutine (5 marks) Extend your list input so that it can be used as a subroutine. 2.3 Checking the order (15 marks) This part will require you to determining whether the given array is in order. Once you have an array of positive numbers, step through this array and store 1 in a variable inOrder where it is in ascending order or 0 otherwise. You should implement this as a subroutine which can be triggered once all the array values have been entered. You may like to display this variable for testing purposes Show transcribed image text 2.1 Inputting a list of numbers (15 marks) The first step is to input a set of numbers (number-by-number, using the Input instruction). You can assume that this will be a set of positive integers and that the last number given will be a zero. This means you can keep reading numbers until you receive a zero. Setup code in MARIE which reads a set of positive integers and stores these as an array (contiguous block of memory) Do not include the 0 in the array; as you accept numbers you should keep track of the size and store this in a variable once all the reading is complete. Print the size of the array using the Output instruction to help you test that your program is correct. 2.2 List input subroutine (5 marks) Extend your list input so that it can be used as a subroutine. 2.3 Checking the order (15 marks) This part will require you to determining whether the given array is in order. Once you have an array of positive numbers, step through this array and store 1 in a variable inOrder where it is in ascending order or 0 otherwise. You should implement this as a subroutine which can be triggered once all the array values have been entered. You may like to display this variable for testing purposes

Expert Answer


Answer to FYI: I’ve completed 2.1 and 2.2, I’m having trouble on 2.3. The code I have right now is: JnS ListInput Halt ListInput,… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *