From mint-bounce@lists.fishpool.fi Thu Aug 11 16:49:01 2005 X-Original-To: fnaumann@mail.boerde.de Delivered-To: fnaumann@mail.boerde.de Subject: Re: [MiNT] what's wrong with this code? From: Odd Skancke To: MiNT List In-Reply-To: <20050810084953.GA29857@hysteria.sk> References: <20050810084953.GA29857@hysteria.sk> Content-Type: text/plain Date: Thu, 11 Aug 2005 16:46:04 +0000 Message-Id: <1123778764.5688.9.camel@linuxbox> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 (2.0.4-4) Content-Transfer-Encoding: 7bit X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-To: mint-bounce@lists.fishpool.fi X-original-sender: ozk@atari.org Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: X-Virus-Scanned: by amavisd-new at relay.boerde.de X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on relay.boerde.de X-Spam-Status: No, hits=-0.9 tagged_above=-50.5 required=7.0 tests=AWL, BAYES_00 X-Spam-Level: Hi, ons, 10,.08.2005 kl. 10.49 +0200, skrev mikro: > Hi, > > I use this dirty trick: > > move.l #set_ssp,$80.w ; install new trap > > ... > > ; this is an exception after trap #0 -> we're in > ; supervisor and we set S bit to get into supervisor > ; after receiving from exception > > set_ssp: bset #5,(a7) ; set S flag > rte > > ... I didnt read all the replies, but I'll comment on this code. First of all, the access to $80.w should give you bus error _UNLESSS_ you are already in SV mode. Second, when you do trap #0 and get to the 'set_ssp' function, forcing the SV mode in the save SR stack will cause havoc once the RTE instruction executes. Why? Because now you use the SV stack in user code after the SR is reloaded and the user stack is just lost. Bad! Bad! Bad! ;-) > > and in my program loop I use: > > andi.w #%1101111111111111,sr ; S = 0 -> User mode > move.l a7,save_usp ; save User SP > > [here do some stuff with a7] > > movea.l save_usp,a7 ; restore user SP > trap #0 ; switch to > ; supervisor Here you have lost your usp! This is a real mess! Just clearing the SV bit does not reload the usp with the value it had before you did your first trap #0. And this goes on, and on.. > > With TOS, Magic, FreeMiNT it works ok. But to the moment I switch MP in FreeMiNT > on. Could someone tell me, what I do wrong? And why it appears just with MP? From the snippet you have here, it amazes me that this works under anything at all. Best Regards, Odd Skancke