Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!snorkelwacker.mit.edu!ai-lab!rice-chex!bson From: bson@rice-chex.ai.mit.edu (Jan Brittenson) Newsgroups: comp.sys.handhelds Subject: Re: HP48: mcode question Message-ID: <12289@life.ai.mit.edu> Date: 8 Dec 90 00:29:08 GMT References: Sender: news@ai.mit.edu Organization: nil Lines: 58 In article kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) writes: > I need a way to push CPU-regs to the RPL-stack during mcode-execution > and have my mcode continuing. The SPRITE routine I posted a couple of weeks ago does this with a `swap_regs' routine. Instead of saving or restoring the RPL context, it swaps it with your registers. Use it to temporarily switch to an RPL context by swapping, manipulating the stack, and swapping again when done. If you want to push a number as a short (system binary), for instance, you can stick the value in R0, swap context, call the routine to push R0 as a short on the stack, and swap back. I've cut it out for you here - others may find it useful as well. O / \/ /\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ O \ ; Switch in/out of RPL context. Wrecks C.a. TOH=#705b0 TOS=#70579 FP=#70574 Free_size=#7066e swap_regs: move.a a,c push.a c swap.a c,d0 move.5 TOH,d0 move.a @d0,a move.a c,@d0 move.5 TOS,d0 move.a @d0,c swap.a c,d1 move.a c,@d0 move.5 FP,d0 move.a @d0,c swap.a c,b move.a c,@d0 move.5 Free_size,d0 move.a @d0,c swap.a d,c move.a c,@d0 move.a a,d0 pop.a c move.a c,a ret