On 10 Sep 2008, at 15:47, Marcel Kilgus wrote:

George Gwilt wrote:
I have never before used this trap but have just now tried it out. It
appears that you have to put the return address on the (user) stack
before Trap #1 otherwise the return is to whatever happens to be on
the user stack which can be rather nasty.

Yes, the normal schema to use it is

        bsr.s   something_nasty
        ; normal stuff
        rts

something_nasty
        moveq   #sms.xtop,d0
        trap    #1

        ; nasty stuff here
        rts

You could also do

        pea     after
        moveq   #sms.xtop,d0
        trap    #1
        
        ; nasty stuff

        rts

after:
        
        ; normal stuff

However, I think the documentation is very slightly misleading. I would not expect to have to use PEA or BSR to load the return address.

George
        
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to