In: Computer Science
Write a MARIE program that implements the following logic.
If X < Y
Then
X = X + Y
Else
Y = 2X
Assume the two numbers are X and Y and are entered by the user. Provide prompts to the user to enter the numbers and provide a meaningful output to the screen.
Answer)
Program:
// Read value of X from user
Input
// Store the value of X
Store X
// Read the value of Y from the user
Input
// Store the value of Y
Store Y
// load X to accumulator(AC)
Load X
// subtracted Y from X
Subt Y
// if the AC is negative skip the next instruction
Skipcond 00
// if the AC is positive jump to else
Jump else
// load X to accumulator(AC)
Load X
// Add Y and content in AC (X + Y)
Add Y
// Store the result in X
Store X
// load X to accumulator(AC)
Load X
// jump to done
Jump done
// load X to accumulator(AC)
else, Load X
// Add X and content in AC (2X)
Add X
// Store the result in Y
Store Y
// load Y to accumulator(AC)
Load Y
// Output the content in AC
done, Output
// END
Halt
// Define X as a decimal and assign 0
X,DEC 0
// Define Y as a decimal and assign 0
Y,DEC 0
Screenshot:
OutPut:
.