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.
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
Get Answers For Free
Most questions answered within 1 hours.