Question

In: Computer Science

Exercise #1:  Write MARIE assembly language code to input 3 values into variables x, y, and z,...

Exercise #1:  Write MARIE assembly language code to input 3 values into variables x, y, and z, calculate x + y -z, and outputs the result. Run your code in the simulator and submit a screen shot of your program run and the code.

//x + y -z

ORG 100
    INPUT
    STORE X
    INPUT
    STORE Y
    INPUT
    STORE Z
    LOAD X
    ADD Y
    SUBT Z
    OUTPUT
    Halt
X, Dec 0
Y, DEC 0
Z, DEC 0

Exercise #2: Write MARIE assembly language code to implement the following algorithm:

Y = 0;
X = 1;
While X < 10 do
Y = Y + X;
X = X + 1;
Endwhile;

So this code calculates the sum of integers between 1 and 9, and stores the result in Y. So after executing the code, the value stored in Y should be decimal 45 i.e. Hexacimal 2D.


ORG 100

    Load X
    Store One
    Test, Subt Ten
    Skipcond 400
    Jump Loop
    Jump Done
    Loop, Load Y
    ADD X
    STORE Y
    Load X
    Add One
    Store X
    Jump Test
    Done, Halt

X, DEC 1
Y, DEC 0
Ten, DEC 10
One, DEC 1

Output:

Input is X = 10, Y = 15, Z = 13

ITS PROGRAMMING

Solutions

Expert Solution

Greetings!!

1.

Code:

INPUT
STORE X
INPUT
STORE Y
INPUT
STORE Z
LOAD X
ADD Y
SUBT Z
OUTPUT
Halt
X, Dec 0
Y, DEC 0
Z, DEC 0

Output screenshot:

2.

Code:

LOOP,     LOAD COUNT
ADD Y
STORE Y
LOAD COUNT
SUBT ONE
STORE COUNT
SKIPCOND 400
JUMP LOOP
LOAD Y
OUTPUT
HALT
Y, DEC 0
COUNT, DEC 9
ONE, DEC 1

Output screenshot:

Hope this helps


Related Solutions

Using the MARIE computer assembly language, write a program that computes the following expression: z =...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. Note: If any of the...
Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The...
Write a parity checker for the ASCII system in MARIE. MARIE is an assembly language. The parity checker should repeatedly execute a loop that performs the following tasks: 1. Ask the user for an input X, which can be any printable ASCII character from Table 1; 2. Output the decimal code of X; 3. Output the total number of 1’s that appears in the binary code of X; 4. Output the parity bit which, when added to the binary code...
Suppose X and Y are independent variables and X~ Bernoulli(1/2) and Y~ Bernoulli(1/3) and Z=X+Y A-...
Suppose X and Y are independent variables and X~ Bernoulli(1/2) and Y~ Bernoulli(1/3) and Z=X+Y A- find the joint probability table B- find the probility distribution table of Z C- find E(X+Y) D- find E(XY) E- find Cov(X, Y)
6.) Write the assembly code for the following piece of code. Note: r,g,y,z correlate with the...
6.) Write the assembly code for the following piece of code. Note: r,g,y,z correlate with the w4, w8, w11, and w15. if (g * y > 25) || (y == z / 8) && (y * 4 < z - g)) y = r / 32; else g = 8 * (r - z);
1.What values of x,  y and z balance the equation: x SO2    +   y H+   +    Cr2O72– → 3...
1.What values of x,  y and z balance the equation: x SO2    +   y H+   +    Cr2O72– → 3 SO42–  + z Cr3+ +   H2O ? 2.What is the stoichiometric ratio of solid phosphorus (P) to chlorine gas (Cl2) required to give phosphorus trichloride (PCl3)? 3.What is the mass fraction of carbon in aniline C6H5NH2 expressed as a percentage? 4. Arrange the following in order of increasing amount of substance: (i)            24 g of sodium metal (ii)           40 g of carbon dioxide...
Python # Write a program that examines three variables—x, y, and z # and prints the...
Python # Write a program that examines three variables—x, y, and z # and prints the largest odd number among them. # If none of them are odd, it should print a message to that effect. n = input('Enter the 1st Integer x: ') x = int(n) n = input('Enter the 2nd Integer y: ') y = int(n) n = input('Enter the 3rd Integer z: ') z = int(n) if x % 2 == 0 and y % 2 ==...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
Write a MARIE program that implements the following logic. If X < Y Then X =...
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.
1) Generate a data set with three variables (X, Y and Z). X and Y have...
1) Generate a data set with three variables (X, Y and Z). X and Y have 10 observations for each (N=10), and Z has 13 observations (N=13). Each observation should have two digits (such as “83” or “8.3”). 2) Draw a stem-and-leaf display for variable Z only and draw a box plot display for variable Z after specifying the 5 numbers (UEX, LEX, FU, FL, MD). 3) Calculate the mean and standard deviation for variable X 4) Calculate the mean...
1) If x, y, z are consecutive integers in order then 9 | (x+y+z) ⟺ 3...
1) If x, y, z are consecutive integers in order then 9 | (x+y+z) ⟺ 3 | y. (Do proof) 2) Let x, y be consecutive even integers then (x+y) is not divisible by 4. (Show proof and state why it was used)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT