In: Computer Science
Create a 32-bit Linux-based assembler language program (nasm) which:
1. Defines these variables:
A: A single byte
B: A word
C: A double word
D: A double word
2. Using the eax register (and its sub-registers), process the following equations (ONLY using the mov, add and sub assembly keywords):
I. A + (B + C) = D
II. (A + C) - B = D
3. Using the linux function library, print a string describing each equation, then values in each variable, and then the answer in the resulting variable
4.Use the following values in your equation:
I. 10h
II. 2000h
III. 30000
Sample Output: The Result of A + (B + C) = D is: 32010
When printing out a string in NASM, use the linux function library call PrintString. Make sure your string is 00h terminated. • When printing out a Hexadecimal value in NASM, use the linux function library call Print32bitNumHex
section .data
msg db "The Result of A + (B + C) = D is
:%d",10,0
msg1 db "The Result of (A + C)-B = D is :%d",0
A dd 10
B dd 2000
C dd 30000
section .bss
D resd 1
section .text
global main
extern printf
main:
;A+(B+C)=D
mov eax,dword[B]
add eax,dword[C]
add eax,dword[A]
mov dword[D],eax
push eax
push msg
call printf
add esp,8
mov eax,dword[A]
add eax,dword[C]
sub eax,dword[B]
mov dword[D],eax
push eax
push msg1
call printf
add esp,8