Question: INCLUDE Irvine 3 2 . inc . data filePath BYTE C: Data reviews . txt , 0 ; Path
INCLUDE Irvineinc
data
filePath BYTE C:Datareviewstxt ; Path to the reviews file
buffer BYTE DUP ; Buffer for reading a line from file
newline BYTE DhAh ; Newline characters
delimiter BYTE ; Delimiter comma
movieScores DWORD DUP ; rows reviewers x columns movies
movieTotals DWORD DUP ; Totals for each movie
movieNames BYTE ABCDE ; Movie names
highestMovie BYTE
highestScore DWORD
msgTotal BYTE "Total scores for each movie:",
msgHighest BYTE "Movie with the highest total score:
errorMsg BYTE "Error reading the file.",
msgFileError BYTE "Unable to open or read the file. Please check the file path.",
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
mov alesi ; Movie letter egB
sub alA ; Convert letter to index
movzx ebx, al ; Movie index store as bit in ebx
add esi, ; Skip to score skip the movie letter and comma
; Parse score
call GetNumber
mov ecx, eax ; ECX score bit
add esi, ; Skip to reviewer ID skip the comma
; Parse reviewer ID
mov alesi ; Get reviewer ID
sub al ; Convert to reviewer index
movzx edx, al ; Reviewer index store as bit in edx
; Update scores in array
mov eax, edx ; Row offset reviewer index
imul eax, ; Multiply by to get row offset each movie has 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 bit
add eax, ecx ; Add new score to current score
mov edi eax ; Store updated score bit
ret
ProcessLine ENDP
GetNumber PROC
xor eax, eax
parseDigit:
mov alesi
cmp al
jb parseEnd
cmp al
ja parseEnd
sub al
imul eax,
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,
add eax, ebx
mov esi, OFFSET movieScores
add esi, eax
add edx, esi
inc ecx
cmp ecx,
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 aleax
mov highestMovie, al
skipHighest:
inc ebx
cmp ebx,
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 dleax
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,
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...",
END main
input file is
D
A
A
B
B
C
D
B
A
C
D
E
A
B
C
E
C
E
D
E
there is no error but file is also reading but there is nothing displayed please fixed and give me full code now
COSC Programming Project 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 to 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 to and the reviewers identifying number. For example, to report that movie B was rated a score of by reviewer there will be a line in the text file that looks like this: B The fields within each record are separated from each other by a comma. Your program must store the movie review scores in a twodimensional array rows by 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
