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 7 row by 9 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, 7
mov esi, OFFSET NUMS
row_loop:
push ecx
mov ecx, 9
column_loop:
mov ax,[esi]
cmp ax,[esi+2]
jl swap
add si,2
loop column_loop
swap:
mov bx,[esi+2]
mov [esi+2], ax x
mov [esi], bx
add esi, 2 Exception Unhandled
loop column_loop
Unhandled exception at 0x00403762 in Project.exe: 0xC0000005: Access
violation writing location 0x00407000.
pop ecx
loop row_loop
Ask Copilot | Show Call Stack | Copy Details | Start Live Share session
Exception Settings
ret
sorting ENDP
Beginning of program with NUMS table:
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
INCLUDE Irvine32.inc
.data
promptNT BYTE "The NUMS table: ",0
promptST BYTE "The Sorted NUMS table: ",0
promptCT BYTE "The Changed NUMS table: ",0
promptSWT BYTE "The Switched NUMS table: ",0
newline BYTE ODh, 0Ah, ODh, 0Ah,0
space BYTE "",0
NUMS WORD 09EEBh, 0B0CFh,061E5h,089EDh, 0AF17h,0D8D1h,06C1Dh,0594Eh,0CF55h
WORD 03767h,063C6h,0AE84h,0412Fh,0B226h,046C1h,0879Bh,076B6h,093FFh
WORD 0AFFFh, 05B8Fh,06164h,01CF7h,09A41h,0A525h,0A5A1h,08F05h,07E4Ch
WORD 0827Ah,090B0h,0722Dh,0BCCFh,033ABh, 0DC76h,085B6h,0AA5Fh,03FB3h
WORD 04BACh, 0B822h,07768h,0BF1Bh,05783h,07EEBh, 09F22h,0B85Bh,05312h
WORD 05971h,0B1B6h,0B16Dh,054B3h,073C8h,0586Bh,08170h,06F16h,092A0h
WORD 09680h,0A23Bh,0B45Dh,01E91h,0415Ah,0B5D9h,02D02h,06748h,03D39h
main PROC:
.code
main PROC ; control section of program
call printPromptNT
call printing ; Print unsorted output in 7 x 9 table format
call printPromptST
call sorting ; sort each row of NUMS table separately
call printing ; Print sorted output in 7 x 9 table format
COMMENT @
call printPromptCT
call changing ; read CHANGES, add value to NUMS table
call printing ; Print changed output in 7 x 9 table format
call printPromptSWT
call switching ; read SWITCHES, exchange NUMS table values
call printing ; Print switched output in 7 x 9 table format
@
exit
main ENDP
P.S.
I know there are calls to other procedures, but I'm trying to figure out this issue with the sorting before messing with any of those first.
I am getting an access violation error in MASM

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!