Question: The following code is for NASM Assembly language . I have attached the assignment , output examples , and my code that doesn't seem to

The following code is for NASM Assembly language. I have attached the assignment, output examples, and my code that doesn't seem to work.

I am having a problem with the ebx variable, where it becomes 10 no matter what my input actually was.

The following code is for NASM Assembly language. I have attached the

Here is my code below, which has a problem with the ebx variable being automatically changed to 10 no matter what the user inputs. I have only coded the multiplication part, which is where ebx is used to multiply the variable eax. The variable eax is where user input is automatically stored. CODE STARTS HERE is where my code starts.

segment .data

segment .bss

segment .text

global asm_main

asm_main:

push ebp

mov ebp, esp

; ********** CODE STARTS HERE **********

start:

call read_int

mov ebx, eax

call read_char

mov ecx, eax

call read_int

mov esi, eax

cmp ecx,'+'

JE add_loop

cmp ecx,'-'

JE sub_loop

cmp ecx,'*'

JE multi_loop

cmp ecx,'/'

JE div_loop

cmp ecx,'%'

JE mod_loop

add_loop:

JMP start

sub_loop:

JMP start

multi_loop:

imul ebx

call print_int

JMP stop

div_loop:

JMP start

mod_loop:

JMP start

stop:

; *********** CODE ENDS HERE ***********

mov eax, 0

mov esp, ebp

pop ebp

ret

My program output below:

assignment, output examples, and my code that doesn't seem to work. I

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!