include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
Init tc
Let esi="40000h"
.While 1
@@: Let esi=Input$("address: ", esi)
.Break .if !Len(esi)
mov ecx, Val(esi)
Print Str$("Dword at %i = ", ecx)
Try
mov eax, [ecx]
Catch
PrintLine "The OS reports:", CrLf$, LastEx(info)
jmp @B
Finally
PrintLine Str$(eax)
.Endw
EndOfCode
Nice, very interesting jj, and works too! :icon14:
Quote from: smid1584 on October 17, 2017, 05:41:23 AM
I have a program that allows the user to ask for the value at any address, valid or invalid. So sometimes it can try to retrieve the value at an address the program does not have access to. An error is thrown ... how do I catch and handle such errors?
There is a post here (http://masm32.com/board/index.php?topic=6614.msg70934#msg70934). Currently, you will not be able to find much better in ASM, because I did a full research. However, the solution is clunky and basically wrong, but will work for easy cases like yours (probably). I am working on another approach, but will take some time because the subject is not easy.