Unhandled exception at 0x0056FC80 in Assignment7.exe: 0xC0000005: Access violation executing location 0x0056FC80.
- Unhandled exception at 0x0056FC80 in Assignment7.exe: 0xC0000005: Access violation executing location 0x0056FC80. When I click build, it is successful but I keep getting this when im debugging! can someone help me fix this?
.386
.model flat, stdcall .stack 4096
ExitProcess PROTO :DWORD WriteConsoleA PROTO :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
.data
numbers DWORD 12345678h, 23456781h, 45678123h, 78654321h, 56781234h
buffer BYTE 9 DUP(0)
```.code
main PROC
; Iterate through each packed decimal integer mov ecx, LENGTHOF numbers mov esi, OFFSET numbers mov edi, OFFSET buffer
; Pass the current packed decimal integer and buffer address to PackedToAsc push edi push [esi] call PackedToAsc add esp, 8 ; Clean up the stack
; Display the ASCII string push OFFSET buffer call writeString add esp, 4
; Move to the next packed decimal integer add esi, 4
; Output a newline character mov edx, OFFSET CRLF call writeString
; Check if all integers have been converted loop convert_loop
; Exit the program INVOKE ExitProcess, 0
; Input: eax = packed decimal integer ; edi = address of buffer to store ASCII digits ; Output: ASCII representation of the packed decimal integer in the buffer
; Initialize index and clear buffer xor ecx, ecx
; Loop through each nibble of the packed decimal integer mov edx, eax ; Copy packed decimal integer shr edx, 28 ; Shift to get the high nibble and edx, 0Fh ; Mask to isolate the nibble add dl, '0' ; Convert to ASCII mov [edi + ecx], dl ; Store in buffer inc ecx
mov edx, eax ; Copy packed decimal integer shr edx, 24 ; Shift to get the second nibble and edx, 0Fh ; Mask to isolate the nibble add dl, '0' ; Convert to ASCII mov [edi + ecx], dl ; Store in buffer inc ecx
mov edx, eax ; Copy packed decimal integer shr edx, 20 ; Shift to get the third nibble and edx, 0Fh ; Mask to isolate the nibble add dl, '0' ; Convert to ASCII mov [edi + ecx], dl ; Store in buffer inc ecx
mov edx, eax ; Copy packed decimal integer shr edx, 16 ; Shift to get the fourth nibble and edx, 0Fh ; Mask to isolate the nibble add dl, '0' ; Convert to ASCII mov [edi + ecx], dl ; Store in buffer inc ecx
; Null-terminate the string mov byte ptr [edi + ecx], 0
ret
writeString PROC
; Input: esi = address of null-terminated string ; Output: string is displayed on console
; Load arguments for WriteConsoleA push -11 ; hConsoleOutput push esi ; lpBuffer mov edx, LENGTHOF buffer - 1 ; Length of the string push edx ; nNumberOfCharsToWrite push 0 ; lpNumberOfCharsWritten call WriteConsoleA ; Call WriteConsoleA to display the string add esp, 16 ; Clean up the stack
ret
CRLF BYTE 0DH, 0AH, 0 ; Newline character sequence
main ENDP
END main