Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly language program that accumulates and reports the sales for th

ID: 3772433 • Letter: W

Question

Write an assembly language program that accumulates and reports the sales for the Albatross Corporation. The Albatross Company has four salespeople who sell five different products. The four salesperson are each identified by a number from 1 to 4. Each products is identified by a number from 1 to 5. Sales are reported by entering the salesperson’s number, the quantity sold, and the product number. For example, to report that salesperson 2 sold 100 units of product 4, you would enter 2 100 4.

Your program must store the sales data in a two-dimensional array (4 rows by 5 columns). Each row represents a salesperson. Each column represents a product. Initialize the array to zeroes and allow your user to enter data. When the user enters a negative number for a salesman number, terminate the input phase of your program and display a report that shows the total sales for each salesperson and the total sales for each product.

Explanation / Answer

.data

askfile BYTE "Enter the data file name: ",0
fileMessage BYTE "Error while opening file: ",0dh,0ah,0
fileName BYTE 256 DUP(0)
byteCount DWORD ?
handle DWORD ?

.code
main PROC

mov edx,OFFSET askfile
call WriteString

;File name

mov edx,OFFSET filename
mov ecx,SIZEOF filename
call ReadString
mov byteCount,eax

;Open

mov edx,OFFSET filename
call OpenInputFile
cmp eax,INVALID_HANDLE_VALUE
je file_error
mov handle,eax
jmp Alpha

file_error:
mov edx,OFFSET fileMessage
call WriteString
jmp Omega

Alpha:
.data
BUFFER_SIZE = 17
buffer BYTE BUFFER_SIZE DUP(?)
bytesRead DWORD ?

.code

;Read from file

mov eax,handle
mov edx,OFFSET buffer
mov ecx,BUFFER_SIZE
call ReadFromFile
jc read_error
cmp eax,BUFFER_SIZE
jl Omega

read_error:
mov edx,OFFSET readMessage
call WriteString
jmp Omega


main ENDP
END main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote