Question: Hello, I need help trying to get my code working. The language is Marie Language. The arrow is point to z so it will look

Hello, I need help trying to get my code working. The language is Marie Language. The arrow is point to z so it will look like something like this Z<-. Here is a copy of my assignment: Using the MARIE computer assembly language, write a program that computes the following expression: z <-(a * b)*(c * d)* e. The computer will read in the input values a, b, c, d, and e from the keyboard, and the final result (z) has to be displayed. In addition, every time an input value is read in, it must be validated by checking that the input is a positive number. If it is positive display the number on the screen; otherwise display zero and end the program. Each time a multiplication of two numbers is needed, it has to be done using a multiplication subroutine. Remember that the MARIE instruction set does not have an instruction to execute multiplication, you must create a subroutine (function) that multiplies two numbers and call it each time you need it. The program must be tested in the MARIE simulator. Here is my code: ORG 100
InputLoop, INP // Read input from keyboard
SUBT One // Subtract 1 to check if positive
SKIPPOS Zero // Skip if negative or zero
OUT // Output the positive number
JUMP InputLoop // Repeat the input loop
Zero, OUT ZeroVal // Output zero if input is negative or zero
HLT // Halt the program
One, DEC 1// Constant value -1
ZeroVal, HEX 0// Constant zero
Start, NOP // Start of the program
JNS APositive // Check if A is positive
JUMP Zero // If not positive, end program
APositive, JNS BPositive // Check if B is positive
JUMP Zero
BPositive, JNS CPositive // Check if C is positive
JUMP Zero
CPositive, JNS DPositive // Check if D is positive
JUMP Zero
DPositive, JNS EPositive // Check if E is positive
JUMP Zero
EPositive, CALL Multiply // Multiply A and B
STA Temp // Store result temporarily
LDA C // Load C
CALL Multiply // Multiply C and D
MUL Temp // Multiply the previous result by the new result
LDA E // Load E
CALL Multiply // Multiply the final result by E
STA Z // Store the final result in memory location Z
LDA Z // Load the final result
OUT // Output the final result
HLT // Halt the program
Multiply, STOR X // Store X
STOR Y // Store Y
LDA Zero // Clear accumulator for result
STOR Result // Store the result
LDA Y // Load Y into the accumulator
JUMPZ Done // If Y is zero, end multiplication
ADD X // Add X to the result
SUBT One // Decrement Y
STOR Y // Store the decremented Y
JUMP Multiply // Repeat multiplication
Done, LDA Result // Load the result
RET // Return from subroutine
A, HEX 0// Input A
B, HEX 0// Input B
C, HEX 0// Input C
D, HEX 0// Input D
E, HEX 0// Input E
Temp, HEX 0// Temporary storage
X, HEX 0// Multiplication variable X
Y, HEX 0// Multiplication variable Y
Result, HEX 0// Result of multiplication
Z, HEX 0// Memory location to store the final result
END Start

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!