Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write an assembly program using MARIE to receive an input in decimal that rep

ID: 3552363 • Letter: 1

Question

1. Write an assembly program using MARIE to receive an input in decimal that represents

the number of numbers in a list. Then input a list of numbers one by one and store each

number in the memory location in sequence (array) using indirect addressing instruction

StoreI. Display the number of numbers of the list as well as the numbers one by one, and

find the sum of numbers from the list using indirect addressing instruction AddI.

In MARIE, there are two more indirect addressing instructions, LoadI and StoreI.

LoadI instruction specifies the address of the address the operand to be loaded to AC.

StoreI instruction specifies the address of the address the operand to be stored from AC.

AddI instruction specifies the address of the address of the operand to be added to AC.

Note:

Keep in mind that you do not know how many number of numbers in the list. That means

you do not know how many variables to declare to store these numbers in your program.

You need to use StoreI to store each number one after the other as an array. That means

use only one variable name to store all the numbers.

Hint:

Use a variable say Addr as an array to store a list of numbers. It is easier to have the

value of Addr as Hex. The value of Addr will be the address of the first number. You

will have to load the program in MARIE first to determine what that value should be. Use

MARIE memory map to determine this memory location. This memory location should

come after the last memory location that your program occupies. Use another variable say

Next as copy of Addr. You always have the starting address of the list of numbers to use.

Explanation / Answer

ORG 000
INPUT
STORE C //Enter the number of numbers
LOOP, CLEAR
LOAD C // C is the number of numbers we are entering
OUTPUT // DIsplays the number of remaining entries
SUBT B //B is 1, the value we subtract from the count C each loop
STORE C
INPUT // inputs the number to be added
STORE D // number is XXXXX in D
OUTPUT // Display the number entered
SKIPCOND 800 // if the number is > 0 we skip the next instruction
JUMP NOADD // jump to NOADD if the number is XXXXX > 0
ADD A //Add the number to A
STORE A // Store the number back in A
NOADD, LOAD A // load A into the accumulator
OUTPUT //Display the total
LOAD C // load the accumulator with the counter value from C
SKIPCOND 400 if it is not equal to 0 jump to the loop label
JUMP LOOP
HALT
A, DEC 0
B, DEC 1
C, DEC 0
D, DEC 0