Question
/* The following code is for NASM Assembly language. I have attached the assignment Please post working code: Thanks, segment .data num1 db 4 num2
/* The following code is for NASM Assembly language. I have attached the assignment
Please post working code:
Thanks, segment .data num1 db 4 num2 db 4
button db 2 segment .bss
segment .text global asm_main
asm_main: push ebp mov ebp, esp
; ********** CODE STARTS HERE **********
start:
call read_int mov num1, eax
call read_char mov button, eax
call read_int mov num2, eax
cmp button, '+' JE addition
cmp button, '-' JE subtraction
cmp button, '*' JE multiplication
cmp button, '/' JE division
cmp button, '%' JE modulus
addition: JMP start subtraction: JMP start multiplication: JMP start division: JMP start modulus: JMP start
stop:
; *********** CODE ENDS HERE *********** mov eax, 0 mov esp, ebp pop ebp ret
Assignment: Calculator Description: Write a calculator program in assembly. It should handle the following functions: addition (+), subtraction (-), multiplication (*), integer division (), modulo division (%), and exponentiation(. Your program should 1. Read an integer from the user 2. Read a character from the user, representing the function. (+,-, *J, % 3. Read another integer from the user 4. Print an equals sign () 5. Print the result Plcase comment your code, and format it so that it looks clean! (examples on next page) Output Examples: andrew@dev:/calculator$ ./calculator 17 - This is input - This is input - This is input -This is output - This is output 28 andrew@de/calculator$ ./calculator 25 74 andrew@dev:/calculator$ ./calculator 10 110 andrew@dev: /calculator$ ./calculator 67 andrew@dev:/calculator$./calculator 67 andrew@dev:/calculator$ ./calculator 64 Assignment: Calculator Description: Write a calculator program in assembly. It should handle the following functions: addition (+), subtraction (-), multiplication (*), integer division (), modulo division (%), and exponentiation(. Your program should 1. Read an integer from the user 2. Read a character from the user, representing the function. (+,-, *J, % 3. Read another integer from the user 4. Print an equals sign () 5. Print the result Plcase comment your code, and format it so that it looks clean! (examples on next page) Output Examples: andrew@dev:/calculator$ ./calculator 17 - This is input - This is input - This is input -This is output - This is output 28 andrew@de/calculator$ ./calculator 25 74 andrew@dev:/calculator$ ./calculator 10 110 andrew@dev: /calculator$ ./calculator 67 andrew@dev:/calculator$./calculator 67 andrew@dev:/calculator$ ./calculator 64Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started