Question: I am getting an access violation error in MASM when part of my sorting procedure is ran on a 7 row by 9 column table
I am getting an access violation error in MASM when part of my sorting procedure is ran on a row by column table named NUMS. Can you spot where I went wrong or any other potential issues with my procedure syntax? Thank you.
sorting PROC ; sort each row of NUMS table separately
mov ecx,
mov esi, OFFSET NUMS
rowloop:
push ecx
mov ecx,
columnloop:
mov axesi
cmp axesi
jl swap
add si
loop columnloop
swap:
mov bxesi
mov esi ax x
mov esi bx
add esi, Exception Unhandled
loop columnloop
Unhandled exception at x in Project.exe: xC: Access
violation writing location x
pop ecx
loop rowloop
Ask Copilot Show Call Stack Copy Details Start Live Share session
Exception Settings
ret
sorting ENDP
Beginning of program with NUMS table:
model flat,stdcall
stack
ExitProcess proto,dwExitCode:dword
INCLUDE Irvineinc
data
promptNT BYTE "The NUMS table:
promptST BYTE "The Sorted NUMS table:
promptCT BYTE "The Changed NUMS table:
promptSWT BYTE "The Switched NUMS table:
newline BYTE ODh, Ah ODh, Ah
space BYTE
NUMS WORD EEBh, BCFhEhEDh, AFhDDhCDhEhCFh
WORD hChAEhFhBhChBhBhFFh
WORD AFFFh, BFhhCFhAhAhAAhFhECh
WORD AhBhDhBCCFhABh, DChBhAAFhFBh
WORD BACh, BhhBFBhhEEBh, FhBBhh
WORD hBBhBDhBhChBhhFhAh
WORD hABhBDhEhAhBDhDhhDh
main PROC:
code
main PROC ; control section of program
call printPromptNT
call printing ; Print unsorted output in x table format
call printPromptST
call sorting ; sort each row of NUMS table separately
call printing ; Print sorted output in x table format
COMMENT @
call printPromptCT
call changing ; read CHANGES, add value to NUMS table
call printing ; Print changed output in x table format
call printPromptSWT
call switching ; read SWITCHES, exchange NUMS table values
call printing ; Print switched output in x table format
@
exit
main ENDP
PS
I know there are calls to other procedures, but Im trying to figure out this issue with the sorting before messing with any of those first.
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
