Question

In: Computer Science

Write a program named subtract.asm that does the following using LC3 assembly language: Print a prompt...

Write a program named subtract.asm that does the following using LC3 assembly language:

Print a prompt "PRESS TWO KEYS: " Note that the prompt MUST LOOK EXACTLY like the above, with a colon and a space after the word KEYS with no newline. Get a two key press from the user. Subtract the second characters ASCII code from the first characters ASCII code. If the result is positive, print the word POSITIVE. Turn in subtract.asm to the appropriate submission point on Web-CAT.

  • All of this code should be in your main portion of the program You do not need subroutines.  
  • You are not allowed to use subroutines and therefore do not need to save registers.

Solutions

Expert Solution

HERE is the CODE:

.LC0:

        .string "PRESS TWO KEYS: "

.LC1:

        .string "%c%c"

.LC2:

        .string "POSITIVE"

.LC3:

        .string "NEGATIVE"

main:

        push    rbp

        mov     rbp, rsp

        sub     rsp, 16

        mov     edi, OFFSET FLAT:.LC0

        mov     eax, 0

        call    printf

        lea     rdx, [rbp-2]

        lea     rax, [rbp-1]

        mov     rsi, rax

        mov     edi, OFFSET FLAT:.LC1

        mov     eax, 0

        call    __isoc99_scanf

        movzx   eax, BYTE PTR [rbp-1]

        movsx   edx, al

        movzx   eax, BYTE PTR [rbp-2]

        movsx   eax, al

        sub     edx, eax

        mov     eax, edx

        test    eax, eax

        jle     .L2

        mov     edi, OFFSET FLAT:.LC2

        mov     eax, 0

        call    printf

        jmp     .L4

.L2:

        mov     edi, OFFSET FLAT:.LC3

        mov     eax, 0

        call    printf

.L4:

        nop

        leave

        ret

SCREENSHOT:


Related Solutions

Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Write an assembly language program that will print out the message of your choosing #NOTE #write...
Write an assembly language program that will print out the message of your choosing #NOTE #write in a simple way, so that i can execute it from command window using masm
Using Java, write a program named MyAngles that will prompt the user for the measure of...
Using Java, write a program named MyAngles that will prompt the user for the measure of the three sides of a triangle and then reports the measurement of each interior angle of the triangle and the area of the triangle.
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality:...
In MPLAB write and compile (using the simulator) an assembly language program with the following functionality: Configures pin RA2 of the PIC24to be an output to control an attached LED. Configures pin RB13 of the PIC24 to be an input to read the value on an attached switch (this switch will connect to ground when pressed). Configures pin RB13 to use the internal pull-up resistor. After configuration, the LED will be "off" when the push-button is pressed, and "on" when...
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...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
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 a program in MIPS assembly language to perform the calculation of the following equation and...
Write a program in MIPS assembly language to perform the calculation of the following equation and save the result accordingly:    f = 5x + 3y + z Assumptions: - Registers can be used to represent variables x, y, z, and f - Initialize x, y, and z to values of your choice. f can be initialized to zero. - Use comments to specify your register usage and explain your logic
Using C++ code, write a program named q5.cpp to print the minimum of the sums x...
Using C++ code, write a program named q5.cpp to print the minimum of the sums x + y^3 and x^3 + y, where x and y are input by a user via the keyboard.
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the maximum number (as integer) Store a multiplication table for all combinations (with some specific eliminations) of value 0 through the maximum number (being entered) into a 2-D array Write a method named printTable to print out the MulitTable, with the following header, public static void printTable(int[][] multitable) In printTable(), when the value of the MultiTable is an odd number, print out Z Must use...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT