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
1. Write a program that does the following. Write in Assembly Language program Loads your student...
1. Write a program that does the following. Write in Assembly Language program Loads your student ID number into memory starting at location 0x2000 0100 a. DO NOT do any conversion on your ID number. If my ID number is 123456789, I should be able to read your ID in memory as 123456789 2. Loads the first six characters of your name, in ASSIC, in to memory right after your student ID. Total of 6 bytes. a. This means that...
Write a program in Python language which will do the following: Write a program to prompt...
Write a program in Python language which will do the following: Write a program to prompt the user to enter a company name, city, state and zip code. Create a dictionary with the data. Output the dictionary. Then remove the city from the dictionary and output again.
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 windows 32 framework , write an assembly language program ; write a procedure to...
Using the windows 32 framework , write an assembly language program ; 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...
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
Using the software Emulator EMU8086, write an assembly program that uses a loop to print "HELLO...
Using the software Emulator EMU8086, write an assembly program that uses a loop to print "HELLO WORLD" 3 times and "LIFE" 2 times. Example: HELLO WORLD HELLO WORLD HELLO WORLD LIFE LIFE   
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT