Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team
Code: Select all
pea stack
move.w #32,-(sp)
trap #1
addq.l #6,sp
Code: Select all
.. here in USER mode...
clr.l -(sp) ; 0 to go to supervisor
move #32,-(sp)
trap #1
addq.l #6,sp ; returns in D0 the old pointer
... here in supervisor mode ...
move.l d0,-(sp) ; set the old pointer
move #32,-(sp)
trap #1
addq.l #6,sp
... back in USER mode ....
Code: Select all
... here in USER
pea myroutine
move #38,-(sp)
trap #14 ; executes myroutine in supervisor
addq.l #6 sp ; and comes back here
.. always in user....
myroutine:
... my instructions in supervisor...
... saving registers that could be modified...
RTS
Code: Select all
move SR,d0 ; Test supervisor mode
btst #13,d0 ; Specialy for relocation
bne.s mode_super_yet ; programs
move.l 4(sp),a5 ; Address to basepage
move.l $0c(a5),d0 ; Length of TEXT segment
add.l $14(a5),d0 ; Length of DATA segment
add.l $1c(a5),d0 ; Length of BSS segment
add.l #$1000,d0 ; Length of stackpointer
add.l #$100,d0 ; Length of basepage
move.l a5,d1 ; Address to basepage
add.l d0,d1 ; End of program
and.l #-2,d1 ; Make address even
move.l d1,sp ; New stackspace
move.l d0,-(sp) ; Mshrink()
move.l a5,-(sp) ;
move.w d0,-(sp) ;
move.w #$4a,-(sp) ;
trap #1 ;
lea 12(sp),sp ;
clr.l -(sp) ; Supervisor mode
move.w #32,-(sp) ;
trap #1 ;
addq.l #6,sp ;
mode_super_yet:
Arne wrote:I am afraid thatThe Atari Profibuch shows this snippet:
- your "solution" is not a solution at all as it leaves garbage on the stack
- your "solution" just hides the real problem somewhere outside the code snippet you provided
Code: Select all
pea stack
move.w #32,-(sp)
trap #1
addq.l #6,sp
Moulinaie wrote:Code: Select all
.. here in USER mode...
clr.l -(sp) ; 0 to go to supervisor
move #32,-(sp)
trap #1
addq.l #6,sp ; returns in D0 the old pointer
... here in supervisor mode ...
move.l d0,-(sp) ; set the old pointer
move #32,-(sp)
trap #1
addq.l #6,sp
... back in USER mode ....
Code: Select all
pea 0
move.w #$20,-(a7)
trap #1
addq.l #6,a7
move.l d0,_save_usp+2
move.l _memtop,a0
suba.l #$1000,a0
move.l a0,a7 * set up stack
_save_usp pea 0
move.w #$20,-(a7)
trap #1
addq.l #6,a7
Foxie wrote:So, it seems the general rule is that when passing a new stack value, the add should be omitted.
mikro wrote:Wrong. You still must addq.l #6, sp when returning from the supervisor. See above for examples.
mikro wrote:Well, try it by yourself -- enter the supervisor with clr.l -(sp), save the old user stack and return with move.l user_stack,-(sp) back to the user mode. You'll clearly see six bytes off. Maybe you haven't noticed I'm not talking about setting supervisor stack but exiting from the supervisor instead as reply to your claim "So, it seems the general rule is that when passing a new stack value, the add should be omitted."
Users browsing this forum: No registered users and 1 guest