Answered step by step
Verified Expert Solution
Question
1 Approved Answer
section . data menu db ' 1 . Add product', 1 0 , ' 2 . Update product quantity', 1 0 db ' 3 .
section data
menu db Add product', Update product quantity',
db Display product', Average inventory level',
db Exit', 'Enter option:
newline db
msgaddproduct db 'Enter product name:
msginputquantity db 'Enter quantity:
msginputprice db 'Enter price:
msgsuccess db 'Operation successful',
msginvalidoption db 'Invalid option',
section bss
option resb
inputbuffer resb ; Buffer for user input
currentproduct resb ; Buffer for the current product
section text
global start
start:
; Display menu
mov eax,
mov ebx,
mov ecx, menu
mov edx, ; Total length of the menu string
int x
; Read user input
mov eax,
mov ebx,
mov ecx, option
mov edx,
int x
; Print newline
mov eax,
mov ebx,
mov ecx, newline
mov edx,
int x
; Process user input
mov aloption
cmp al
je addproduct
cmp al
je updateproductquantity
cmp al
je displayproduct
cmp al
je calculateaverageinventory
cmp al
je exitprogram
; Invalid option
jmp invalidoption
addproduct:
; Prompt for product name
mov eax,
mov ebx,
mov ecx, msgaddproduct
mov edx, ; Length of the prompt string
int x
; Read product name
mov eax,
mov ebx,
mov ecx, inputbuffer
mov edx,
int x
; Display success message
mov eax,
mov ebx,
mov ecx, msgsuccess
mov edx,
int x
; Restart menu
jmp start
updateproductquantity:
; Prompt for product quantity
mov eax,
mov ebx,
mov ecx, msginputquantity
mov edx, ; Length of the prompt string
int x
; Read product quantity
mov eax,
mov ebx,
mov ecx, inputbuffer
mov edx,
int x
; Display success message
mov eax,
mov ebx,
mov ecx, msgsuccess
mov edx,
int x
; Restart menu
jmp start
displayproduct:
; Prompt for product details not implemented
mov eax,
mov ebx,
mov ecx, msgaddproduct
mov edx, ; Length of the prompt string
int x
; Read product ID or details not implemented
mov eax,
mov ebx,
mov ecx, inputbuffer
mov edx,
int x
; Display success message
mov eax,
mov ebx,
mov ecx, msgsuccess
mov edx,
int x
; Restart menu
jmp start
calculateaverageinventory:
; Logic to calculate and display average inventory not implemented
; Display success message
mov eax,
mov ebx,
mov ecx, msgsuccess
mov edx,
int x
; Restart menu
jmp start
invalidoption:
; Display invalid option message
mov eax,
mov ebx,
mov ecx, msginvalidoption
mov edx, ; Length of the error message
int x
; Restart menu
jmp start
exitprogram:
; Exit the program
mov eax,
xor ebx, ebx
int x fix my code
Step 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