View Single Post
Old 06 August 2018, 11:35   #1
Registered User

Cv365's Avatar
Join Date: Sep 2015
Location: Amigaville
Posts: 21
Exceptions in WinUAE debugger after RTS

Hi! I'm just getting my feet wet with assembler and practising doing system calls. I have a very simple program that allocates some chip mem, frees is and exits.

If I run this on the commandline without setting breakpoints / using the debugger, it exits with no problem. However, if I add a watch/breakpoint on memory location $100, which is cleared at the beginning of my code (thanks for the great tip, Toni!) and I step through each instruction using the built-in WinUAE debugger, something goes horribly wrong after the last instruction (RTS).

After the RTS, the debugger spews out a seemingly neverending loop of Exceptions (number 26 and 27), which locks up the debugger window, due to the scrolling. I can only close the debugger window using its window close gadget. Not long after, the Amiga locks up and reboots.

I am sure I am missing something important here due to my noobishness. Is it something wrong with my code, or is it being caused somehow by using the debugger? Here's my code:

    INCLUDE "exec/types.i"
    INCLUDE "exec/memory.i"
    INCLUDE "exec/exec_lib.i"


    CLR.W	$100			            ; breakpoint for debug
    MOVEA.L	$00000004,A6		        ; load ExecBase
    MOVE.L	#32,D0			            ; how many bytes to alloc
    MOVE.L	#MEMF_CHIP|MEMF_CLEAR,D1    ; memory attribs
    JSR 	_LVOAllocMem(A6)	        ; allocate it
    MOVEA.L	D0,A1			            ; start of allocd mem
    MOVE.L	#32,D0			            ; size
    JSR	_LVOFreeMem(A6)		            ; free it
    CLR.L	D0			                ; return zero to system
    RTS				                    ; done
P.S.: I know I'm not checking whether AllocMem succeeds in my code, but in the debugger I have confirmed that the call succeeds. I have also tried allocating Fast mem. Same deal.
Cv365 is offline  
Page generated in 0.04270 seconds with 11 queries