Question

Implement the following C++ expression val1 = (val2 * val3) / (val4 − 3) in assembly...

Implement the following C++ expression val1 = (val2 * val3) / (val4 − 3) in assembly language
using:
• 8-bit unsigned operands
• 16- bit unsigned operands
• 32-bit unsigned operands
a- Use the MASM assembler with .Data to initialize your variables, write your code in
the .code segment. Add comments explaining your code
b- Modify the code to prompt the user to enter the information -use 32-bit unsigned
operands only-, and show the output on the console, and dump your registers as
well using Irvine32 library
Copy, paste and save your code into a word document. Add a screen shot of the registers
before, during and at the end of the debugging mode.

Homework Answers

Answer #1

NOTE :- MASM compiler :- x86-64 gcc (latest)

32-bit unsigned operands :-

mov edx, DWORD PTR val2[rip]

mov eax, DWORD PTR val3[rip]

imul eax, edx

mov edx, DWORD PTR val4[rip]

lea ecx, [rdx-3]

mov DWORD PTR [rbp-4], ecx

mov edx, 0

div DWORD PTR [rbp-4]

mov DWORD PTR val1[rip], eax

16-bit unsigned operands :-

movzx eax, WORD PTR val2[rip]

movzx edx, ax

movzx eax, WORD PTR val3[rip]

movzx eax, ax

imul eax, edx

movzx edx, WORD PTR val4[rip]

movzx edx, dx

lea ecx, [rdx-3]

mov DWORD PTR [rbp-4], ecx

cdq

idiv DWORD PTR [rbp-4]

mov WORD PTR val1[rip], ax

8-bit unsigned operands :-

  

movzx eax, BYTE PTR val2[rip]

movzx edx, al

movzx eax, BYTE PTR val3[rip]

movzx eax, al

imul eax, edx

movzx edx, BYTE PTR val4[rip]

movzx edx, dl

lea ecx, [rdx-3]

mov DWORD PTR [rbp-4], ecx

cdq

idiv DWORD PTR [rbp-4]

mov BYTE PTR val1[rip], al

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Implement the following expression in assembly language:                                  &nb
Implement the following expression in assembly language:                                                 BX = –val2 + 7 - (- val3 + val1) * 2 Assume that val1, val2, and val3 are 8-bit integer variables Initialize val1 with 12, val2 with 9, and val3 with 2 You are only allowed to use 16-bit registers to hold intermediate results, whenever needed. Use ONLY mov, add, sub, movzx, movzx, or neg instructions whenever needed. Use the debugger to verify your answer. Please answer using this format for...
First clear all your general purpose registers by moving the value “0” into them. Initialize a...
First clear all your general purpose registers by moving the value “0” into them. Initialize a variable for a BYTE, WORD, DWORD storage size each with any desired value in the data segment. Initialize another variable called Result with the size of a DWORD and make the value as an uninitialized value. In the code segment, create a label called L1 that moves the variables in the appropriate sized register and making sure NOT to overwrite them in the process....
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 6.) Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...