Question

In: Computer Science

**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...

**IN AT&T ASSEMBLY LANG**

Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions.

  1. A * 5

  1. (A + B) - (A / B)
  1. (A - B) + (A * B)

Solutions

Expert Solution

Assembly language program to perform the following functions

  • Define two integers
  • Process the three function
  • A * 5
  • (A + B) - (A / B)
  • (A - B) + (A * B)

Source code(Note: Assembly Language x86-64 gcc 10.2 is used and run on exact compiler for the best result)

.LC0:
        .string "Enter first integer number: "
.LC1:
        .string "Enter second integer number: "
.LC2:
        .string "The result of A * 5 is :"
.LC3:
        .string "The result of (A + B) - (A / B) is :"
.LC4:
        .string "The result of (A - B) + (A * B) is :"
main:
        push    rbp
        mov     rbp, rsp
        sub     rsp, 16
        mov     esi, OFFSET FLAT:.LC0
        mov     edi, OFFSET FLAT:_ZSt4cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        lea     rax, [rbp-4]
        mov     rsi, rax
        mov     edi, OFFSET FLAT:_ZSt3cin
        call    std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
        mov     esi, OFFSET FLAT:.LC1
        mov     edi, OFFSET FLAT:_ZSt4cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        lea     rax, [rbp-8]
        mov     rsi, rax
        mov     edi, OFFSET FLAT:_ZSt3cin
        call    std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
        mov     esi, OFFSET FLAT:.LC2
        mov     edi, OFFSET FLAT:_ZSt4cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        mov     rcx, rax
        mov     edx, DWORD PTR [rbp-4]
        mov     eax, edx
        sal     eax, 2
        add     eax, edx
        mov     esi, eax
        mov     rdi, rcx
        call    std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
        mov     esi, OFFSET FLAT:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
        mov     rdi, rax
        call    std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
        mov     esi, OFFSET FLAT:.LC3
        mov     edi, OFFSET FLAT:_ZSt4cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        mov     rcx, rax
        mov     edx, DWORD PTR [rbp-4]
        mov     eax, DWORD PTR [rbp-8]
        lea     esi, [rdx+rax]
        mov     eax, DWORD PTR [rbp-4]
        mov     edi, DWORD PTR [rbp-8]
        cdq
        idiv    edi
        mov     edx, eax
        mov     eax, esi
        sub     eax, edx
        mov     esi, eax
        mov     rdi, rcx
        call    std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
        mov     esi, OFFSET FLAT:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
        mov     rdi, rax
        call    std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
        mov     esi, OFFSET FLAT:.LC4
        mov     edi, OFFSET FLAT:_ZSt4cout
        call    std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
        mov     rdx, rax
        mov     eax, DWORD PTR [rbp-4]
        mov     ecx, DWORD PTR [rbp-8]
        sub     eax, ecx
        mov     esi, eax
        mov     ecx, DWORD PTR [rbp-4]
        mov     eax, DWORD PTR [rbp-8]
        imul    eax, ecx
        add     eax, esi
        mov     esi, eax
        mov     rdi, rdx
        call    std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
        mov     eax, 0
        leave
        ret
__static_initialization_and_destruction_0(int, int):
        push    rbp
        mov     rbp, rsp
        sub     rsp, 16
        mov     DWORD PTR [rbp-4], edi
        mov     DWORD PTR [rbp-8], esi
        cmp     DWORD PTR [rbp-4], 1
        jne     .L5
        cmp     DWORD PTR [rbp-8], 65535
        jne     .L5
        mov     edi, OFFSET FLAT:_ZStL8__ioinit
        call    std::ios_base::Init::Init() [complete object constructor]
        mov     edx, OFFSET FLAT:__dso_handle
        mov     esi, OFFSET FLAT:_ZStL8__ioinit
        mov     edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
        call    __cxa_atexit
.L5:
        nop
        leave
        ret
_GLOBAL__sub_I_main:
        push    rbp
        mov     rbp, rsp
        mov     esi, 65535
        mov     edi, 1
        call    __static_initialization_and_destruction_0(int, int)
        pop     rbp
        ret

The output

  

T


Related Solutions

AT&T x64/GNU Assembly syntax only please Write an assembly language program which either hardcodes or reads...
AT&T x64/GNU Assembly syntax only please Write an assembly language program which either hardcodes or reads in the lengths of the sides of a triangle, and outputs a truthy value (1, “true”, “yes”, and others) indicating whether the triangle is a valid one or not (0, “false”, “no”, etc). A triangle is valid if the sum of each pair of sides is greater than the unpaired side. Meaning if a, b, c are the three sides of a triangle, then...
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers,...
Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. 1) A * 5 2) (A + B) - (A / B) 3) (A - B) + (A * B)
1. Write an assembly language program that prompts the user for and reads four integers (x1,...
1. Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which. 2. Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as “The surface area of the sphere is: …”. Hint: The distance between the points is...
Write an assembly language program that reads move review information from a text file and reports...
Write an assembly language program that reads move review information from a text file and reports the overall scores for each movie as well as identifying the movie with the highest total score. There are four movie reviewers numbered from 1 to 4. They are submitting reviews for five movies, identified by the letters from “A” through “E”. Reviews are reported by using the letter identifying the movie, the review rating, which is a number from 0 to 100, and...
Write a mips assembly language program that asks the user to enter an alphabetic character (either...
Write a mips assembly language program that asks the user to enter an alphabetic character (either lower or upper case)and change the case of the character from lower to upper and from upper to lower and display it.
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 mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Assembly Language for x86 processors You are to write a program which should first ask for...
Assembly Language for x86 processors You are to write a program which should first ask for 4 random numbers from 0-20 (user will inpute these numbers in no preset order). Input these 5 numbers in variables called num1, num2, num3, num4, and num5. When done, your program should sort these numbers (you will use lots of conditions to check order). num1 should contain smallest number while num5 should contain the biggest. display the contents of num1 through num5 on the...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT