Question

In: Computer Science

Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:               ...

  1. Given the below pseudocode, write the proper code that implements it using MARIE's assembly language:

                   Input a number and store it in X;

if X > 1 then

   Y := X + X;

   X := 0;

endif;

Y := Y + 1;

Output the value of Y;

N.B: You should include the MARIE code in your Answer, with an explanation of each instruction in your code beside it.

Example:              Subt One         /Subtract 1 from AC

  1. Add a screenshot of the simulation, showing the result (A screenshot of the MARIE Simulator window after running the program).

Instructions:

  • Use “ORG” instruction to start your program at address 100.
  • Use your last university ID number to input the new value of X.

For example, if your ID is1915161678234, then you will use the number 4 as the value of x.

  • Do not forget to change the representation of the Input and Output windows in the simulator to Decimal.
  • The following labels and directives should be included at the end of your program:

X,      Dec 0

Y,      Dec 12

One,      DEC 1

Solutions

Expert Solution

MARIE PROGRAM

  ORG 100 //start program at address 100
        INPUT     //Get input from user which stores in AC
        STORE X //store  AC value in input
        SUBT One       //subtract 1 from AC
        SUBT One       //subtract 1 from AC
        SKIPCOND 000   //if AC < 0 skip next instruction
        JUMP Cond      //jump to Cond instructions
        JUMP Done      //jump to Done instructions
Cond,   LOAD X         //store X value in AC 
            ADD X          //Add X and AC and store result in Ac
            STORE Y        //store AC value in Y
            LOAD Zero      //store 0 in AC
            JUMP Done      //jump to Done instructions

Done,   LOAD Y         //store Y value in AC
            ADD One        //add 1 to AC
            OUTPUT         //Dispaly AC
            HALT           //End Program
            STORE X        //store X value in Ac
X,    DEC 0             //Initialize X with value 0
Y,    DEC 12            //Initialize Y with value 12
One,  DEC 1          //Initialize One with value 1
Zero, Dec 0          //Initialize Zero with value 0

MARIE PROGRAM SCREENSHOT

OUTPUT SCREENSHOT


Related Solutions

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 MIPS assembly language procedure that implements the Towers of Hanoi recursive function given the...
Write a MIPS assembly language procedure that implements the Towers of Hanoi recursive function given the following declaration: void towers(int n, char source, char dest, char spare); The function outputs a message describing each move. The source, destination, and spare poles are indicated with a character identifier of your choosing ('A', 'B', 'C' are common). Write a MIPS assembly language program that demonstrates the Towers of Hanoi procedure. Your program should ask the user for the number of disks. The...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
write code with proper comments for ever step the code should be in form of pseudocode                            &
write code with proper comments for ever step the code should be in form of pseudocode                                    To Print Triangle of any size, by taking size as input. To Print Triangle of any size, by taking size as input. If size is 4 then triangle is: To calculate Factorial of any number. To calculate the power of any given number. To Print Table of Any Number up till 10: as shown in this figure. for a program which reads 10 integers...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read...
Need to code this is assembly language. Using the windows32 framework, write a procedure to read a string and shift each character of the string by one. As an example, if your input string is Abcz, your output should be Bcda. Note that you must test your string for non-alphabetic characters (such as numbers and special characters). If there are non-alphabetic characters, you should terminate your program with an appropriate message. You should display your converted string using the output...
Using x86 assembly language, create a flowchart and write an example of code that will sort...
Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is...
Write an MSP430 assembly language program that implements the following algorithm: a macro called "vdot" that...
Write an MSP430 assembly language program that implements the following algorithm: a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as “arrays” (following the “C” language convention), of 3 elements. the macro should receive 2 pointers to the first element of each vector and return the result in R13. I have another file where I save my vectors called, "vars.c" here I save: int a[] = { 14, 65, 9} int b[] =...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that sums up all the numeric characters present in a phrase ("string" that follows the "C" language convention). By For example, if the phrase is "Today is the 28th of month 9", the subroutine must perform the following sum: 2 + 8 + 9 = 19. The subroutine must receive the address of the first character of the corresponding phrase in the "stack", and return...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that sums up all the numeric characters present in a sentence (“string” that follows the “C” language convention). For example, if the phrase is "Today is the 21st of month 5", the subroutine must perform the following sum: 2 + 1 + 5 = 8. The subroutine must receive the address of the first character of the corresponding phrase in the " stack ”, and...
Write hack assembly language code for eq lt gt
Write hack assembly language code for eq lt gt
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT