Question: INCLUDE Irvine 3 2 . inc . data filePath BYTE C: Data reviews . txt , 0 ; Path

INCLUDE Irvine32.inc
.data
filePath BYTE "C:\\Data\\reviews.txt",0 ; Path to the reviews file
buffer BYTE 128 DUP(0) ; Buffer for reading a line from file
newline BYTE 0Dh,0Ah,0 ; Newline characters
delimiter BYTE ",",0 ; Delimiter (comma)
movieScores DWORD 15 DUP(0) ; 3 rows (reviewers) x 5 columns (movies)
movieTotals DWORD 5 DUP(0) ; Totals for each movie
movieNames BYTE "A","B","C","D","E",0 ; Movie names
highestMovie BYTE "",0
highestScore DWORD 0
msgTotal BYTE "Total scores for each movie:", 0
msgHighest BYTE "Movie with the highest total score: ",0
errorMsg BYTE "Error reading the file.", 0
msgFileError BYTE "Unable to open or read the file. Please check the file path.", 0
.code
main PROC
call Clrscr
mov edx, OFFSET filePath
call OpenInputFile
jc fileError ; Jump if file cannot be opened
processFile:
mov edx, OFFSET buffer
mov ecx, SIZEOF buffer
call ReadString
jc doneReading
; Process the current line
lea esi, buffer
call ProcessLine
jmp processFile
doneReading:
call ComputeTotals
call DisplayResults
call CloseHandle ; Manually close file handle
call PauseProgram ; Pause program before exiting
jmp exitProgram
fileError:
mov edx, OFFSET msgFileError
call WriteString
call Crlf
call PauseProgram ; Pause to see the error message
jmp exitProgram
exitProgram:
exit
main ENDP
ProcessLine PROC
; Extract and process line: "B,87,3"
mov al,[esi] ; Movie letter (e.g.,'B')
sub al,'A' ; Convert letter to index (0-4)
movzx ebx, al ; Movie index (0-4), store as 32-bit in ebx
add esi, 2 ; Skip to score (skip the movie letter and comma)
; Parse score
call GetNumber
mov ecx, eax ; ECX = score (32-bit)
add esi, 1 ; Skip to reviewer ID (skip the comma)
; Parse reviewer ID
mov al,[esi] ; Get reviewer ID ('1','2','3')
sub al,'1' ; Convert to 0,1,2(reviewer index)
movzx edx, al ; Reviewer index (0-2), store as 32-bit in edx
; Update scores in array
mov eax, edx ; Row offset (reviewer index)
imul eax, 5 ; Multiply by 5 to get row offset (each movie has 5 columns)
add eax, ebx ; Add movie index to row
mov edi, OFFSET movieScores
add edi, eax ; Get correct address in movieScores
mov eax, [edi] ; Current score (32-bit)
add eax, ecx ; Add new score to current score
mov [edi], eax ; Store updated score (32-bit)
ret
ProcessLine ENDP
GetNumber PROC
xor eax, eax
parseDigit:
mov al,[esi]
cmp al,'0'
jb parseEnd
cmp al,'9'
ja parseEnd
sub al,'0'
imul eax, 10
add eax, eax
inc esi
jmp parseDigit
parseEnd:
ret
GetNumber ENDP
ComputeTotals PROC
xor ebx, ebx
nextMovie:
xor ecx, ecx
xor edx, edx
nextReviewer:
mov eax, ecx
imul eax, 5
add eax, ebx
mov esi, OFFSET movieScores
add esi, eax
add edx, [esi]
inc ecx
cmp ecx, 3
jl nextReviewer
mov eax, OFFSET movieTotals
add eax, ebx
mov [eax], edx
cmp edx, highestScore
jbe skipHighest
mov highestScore, edx
lea eax, movieNames
add eax, ebx
mov al,[eax]
mov highestMovie, al
skipHighest:
inc ebx
cmp ebx, 5
jl nextMovie
ret
ComputeTotals ENDP
DisplayResults PROC
mov edx, OFFSET msgTotal
call WriteString
call Crlf
xor ebx, ebx
nextDisplay:
lea eax, movieNames
add eax, ebx
mov dl,[eax]
call WriteChar
mov edx, OFFSET ": "
call WriteString
mov eax, OFFSET movieTotals
add eax, ebx
mov eax, [eax]
call WriteDec
call Crlf
inc ebx
cmp ebx, 5
jl nextDisplay
mov edx, OFFSET msgHighest
call WriteString
mov al, highestMovie
call WriteChar
call Crlf
ret
DisplayResults ENDP
PauseProgram PROC
; Pause program and wait for user input
mov edx, OFFSET msgPressAnyKey
call WriteString
call Crlf
call ReadChar ; Wait for user input
ret
PauseProgram ENDP
.data
msgPressAnyKey BYTE "Press any key to exit...", 0
END main
input file is
D,84,2
A,90,3
A,87,1
B,35,2
B,100,1
C,75,1
D,84,1
B,87,2
A,0,2
C,25,2
D,45,3
E,35,3
A,90,1
B,100,3
C,75,3
E,35,1
C,78,2
E,35,2
D,100,3
E,0,3
there is no error but file is also reading but there is nothing displayed please fixed and give me full code now
COSC 2425 Programming Project 4 Write an assembly language program that reads movie review information from a text file and reports the overall scores for each movie as well as identifying the movie with the highest total score. There are three movie reviewers numbered from 1 to 3. They are submitting reviews for five movies, identified by the letters from A through E. Reviews are reported by using the letter identifying the movie, the review rating, which is a number from 0 to 100, and the reviewers identifying number. For example, to report that movie B was rated a score of 87 by reviewer 3, there will be a line in the text file that looks like this: B,87,3 The fields within each record are separated from each other by a comma. Your program must store the movie review scores in a two-dimensional array (3 rows by 5 columns). Each row represents a reviewer. Each column represents a movie. Initialize the array to zeroes and read the movie rev

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 Programming Questions!