Assembly Language Programming (x86) Project Write an assembly language program t
ID: 3572165 • Letter: A
Question
Assembly Language Programming (x86)
Project
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 ; data section
askfile BYTE "Enter the data file name: ",0 ; here to enter the data file name
fileMessage BYTE "Error while opening file: ",0dh,0ah,0 ; here file message byte used for showing error
fileName BYTE 256 DUP(0)
byteCount DWORD ?
handle DWORD ?
.code ; main program code here
main PROC
mov edx,OFFSET askfile ; OFFSET askfile to edx
call WriteString ; call WriteString procedure
mov edx,OFFSET filename
mov ecx,SIZEOF filename
call ReadString ; call ReadString procedure
mov byteCount,eax ; move eax to byteCount
mov edx,OFFSET filename ; OFFSET askfile to edx
call OpenInputFile ; call OpenInputFile procedure
cmp eax,INVALID_HANDLE_VALUE ; this code used to compare eax,INVALID_HANDLE_VALUE
je file_error
mov handle,eax ; move eax to handle
jmp Alpha ; here the jump instruction is used
file_error:
mov edx,OFFSET fileMessage ; OFFSET fileMessage to edx
call WriteString ; call WriteString procedure
jmp Omega ; jump omega used here
Alpha:
.data ; .data to reserving the storage of data
BUFFER_SIZE = 17 ; buffer size is 17
buffer BYTE BUFFER_SIZE DUP(?)
bytesRead DWORD ?
.code
; next step is read from file
mov eax,handle ;move handle to eax
mov edx,OFFSET buffer ;OFFSET buffer to edx
mov ecx,BUFFER_SIZE ; move BUFFER_SIZE to ecx
call ReadFromFile ; call ReadFromFile procedure
jc read_error ; jump if carry set used here
cmp eax,BUFFER_SIZE ; then compare eax,BUFFER_SIZE
jl Omega ; after comparing eax,BUFFER_SIZE jl is used
read_error: ; read error
mov edx,OFFSET readMessage ; OFFSET readMessage to edx
call WriteString ; call WriteString procedure
jmp Omega ; jump instruction used here
main ENDP ; END procedure
END main ; END
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.