Question

In: Computer Science

Assembly Language Programming Exercise. Problem # 1: 1. Integer Expression Calculation( 5 pts ) Using the...

Assembly Language Programming Exercise. Problem # 1:

1. Integer Expression Calculation( 5 pts )
Using the AddTwo program from Section 3.2 as a reference, write a program that calculates the
following expression, using registers: A = (A + B) − (C + D). Assign integer values to the EAX,
EBX, ECX, and EDX registers.

Solutions

Expert Solution

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

.code
main PROC

mov eax, 5
mov ebx, 7
mov ecx, 4
mov edx, 1

add eax, ebx
add ecx, edx
sub eax, ecx

INVOKE ExitProcess,0
main ENDP
END main

Explanation:

In the code above mov indicates moving values to the register

mov eax, 5 - storing integer value 5 in register eax ( A = 5 )
mov ebx, 7 - storing integer value 7 in register eax ( B = 7 )
mov ecx, 4- storing integer value 4 in register eax ( C = 4 )
mov edx, 1- storing integer value 1 in register eax ( D = 1 )

add indicates addition operation

add eax, ebx - adding the values in register eax and ebx and stores the result in register eax
add ecx, edx- adding the values in register ecx and edx and stores the result in register ecx

sub indicates subtraction operation
sub eax, ecx - Subtracting the values in register eax and ecx and stores the result in register eax(This will be the final result)


Related Solutions

Assembly Language Programming Exercise 5. Listing File for AddTwoSum ( 5 pts ) Generate a listing...
Assembly Language Programming Exercise 5. Listing File for AddTwoSum ( 5 pts ) Generate a listing file for the AddTwoSum program and write a description of the machine code bytes generated for each instruction. You might have to guess at some of the meanings of the byte values. Hint: Watch my tutorial and read a little bit of Ch 4.
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...
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing...
(20 pts) Using your programming language of choice (from C++, Java, or Python) , also drawing on your experience from program 1, read an integer, n from keyboard (standard input). This integer represents the number of integers under consideration. After reading that initial integer in, read n integers in, and print the minimum and maximum of all the integers that are read in. Example: Input Output 7 1 5 3 6 9 22 2 Min: 1 Max: 22 C++ preferred
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
Write a MIPS assembly language to transpose a square integer matrix in code
Write a MIPS assembly language to transpose a square integer matrix in code
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer"...
need a code MIPS assembly language program to implement algorithms of an 8-bit integer "positive integer" to calculate the square root for an-8 bit integer using The Radix-2 SRT-Redundant and Non-Redundant Algorithm to approximate square root
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing...
C Programming Language (Code With C Programming Language) Problem Title : Which Pawn? Jojo is playing chess himself to practice his abilities. The chess that Jojo played was N × N. When Jojo was practicing, Jojo suddenly saw a position on his chessboard that was so interesting that Jojo tried to put the pieces of Rook, Bishop and Knight in that position. Every time he put a piece, Jojo counts how many other pieces on the chessboard can be captured...
Use MIPS assembly language program to swap two of the integers in an integer array. The...
Use MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. The main function should: • Pass the starting address of the array in $a0. • Pass the indices of the two elements to swap in $a1 and $a2. • Preserve (i.e. push onto the stack) any T registers that it uses. • Call the Swap...
in assembly show output too - thanks . Translate the following expression to Assembly: a. 5...
in assembly show output too - thanks . Translate the following expression to Assembly: a. 5 x (10 + 13) b. 5 - 4 x 4 c. AX = FF50h - ABCDh d. EAX = (EBX - 4) x (-1) e. EAX = 0 EBX = 9 ECX = 10 X = EAX x EBX - ECX
R programming language A) Create a function that accepts two arguments, an integer and a vector...
R programming language A) Create a function that accepts two arguments, an integer and a vector of integers. It returns the count of the number of occurrences of the integer in the input vector. 1]Input: num_count <-function ??? 2]Input: num_count(2,c(1,1,2,2,3,3)) 2] Output: 2 3] Input: num_count(1,c(1,1,2,2,3,1,4,5,5,2,2,1,3)) 3] Output : 4 B) Create a function that accepts 3 integer values and returns their sum. However, if an integer value is evenly divisible by 3, then it does not count towards the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT