[net.micro.atari16] Supervisor mode

cabbie@chinet.UUCP (Richard Andrews) (10/23/86)

	I want to do some hardware tweaking and mave been attempting
to enter supervisor mode but am still getting bus errors?  Does
anyone have some general purpose source code to do this?

					Thanks,
		
					Rich Andrews
					...ihnp4!chinet!cabbie

sansom@trwrb.UUCP (Richard Sansom) (10/28/86)

In article <660@chinet.UUCP> cabbie@chinet.UUCP (Richard Andrews) writes:
>
>	I want to do some hardware tweaking and mave been attempting
>to enter supervisor mode but am still getting bus errors?  Does
>anyone have some general purpose source code to do this?
>

Gemdos function 0x20 is the one you want:

Call:	Super(stack);	- or -	    gemdos(0x20, stack);

where "stack" is a pointer to your supervisor stack or NULL (0L) if you
want to use the user stack as supervisor stack.  The function returns a
pointer to the old supervisor stack.  You MUST restore the stack to this
value when you exit supervisor mode or else the machine  will crash.

C code example:

    long    old_ssp;		/* old supervisor stack pointer */

    old_ssp = Super(0L);	/* enter supervisor mode, use the user stack*/

    /* your super code goes here */

    Super(old_ssp);		/* exit supervisor mode, restore stack */

Assembly example:

    clr.l   -(sp)		; pass a long zero (use user stack)
    move.w  #$20,-(sp)		; pass gemdos function 0x20
    trap    #1			; enter supervisor mode
    add.l   #6,sp		; clean up the stack
    move.l  d0,old_ssp		; save old stack pointer

; your super code goes here

    move.l  old_ssp,-(sp)	; pass the old stack pointer
    move.w  #$20,-(sp)		; pass gemdos function 0x20
    trap    #1			; exit supervisor mode
    add.l   #6,sp		; clean up the stack

-Rich

-- 
 __________ ______ ____ _____ ___
/_________//___   ||__|/____|/__/   Richard E. Sansom
   ___    ____/  / ____________     TRW Electronics & Defense Sector
  /  /   /  /\  <  |    /|    /     One Space Park Drive, R3/1028
 /  /   /  /  \  \ |   / |   /      Redondo Beach, CA 90278
/__/   /__/    \__\|__/  |__/       {...decvax,ucbvax,ihnp4}!trwrb!sansom