[comp.sys.handhelds] HP48: mcode question

kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) (12/07/90)

hello,

I need a way to push CPU-regs to the RPL-stack during mcode-execution
and have my mcode continuing.

I need this for routines that don't know the number of results
forehand. I want to push them all to the stack and then put
them into a list (ore something like that) by a RPL-program
after the mcode did its work.
eg: factoring by trial division would look like this
    -- push the factors as you find them in mcode
    -- use RPL to make a decent result

Any ideas or even good addresses ?

Thanx, -KK
------------------------------------------------------------------------------
   Klaus Kalb    | mail :  IMMD1 / Martenstr. 3 / W-8520 Erlangen / Germany   
                 | email:  kskalb@immd1.informatik.uni-erlangen.de   
------------------------------------------------------------------------------
                  

bson@rice-chex.ai.mit.edu (Jan Brittenson) (12/08/90)

In article <kskalb.660423859@faui1f> 
   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

kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) (01/25/91)

Hello,

Alonzo Gariepy says in his processor notes for the HP28 (at least in my copy)

--> It is said that R4 is used by the interrupt handler, but I have yet to
--> confirm it.

My question is:

--- Is it save to use R4 in mcode programs on the HP48 ?
    Or is that register indeed overwritten by the interrupt handler ?

Thanx,
-KK

PS:
I've posted a integer factorization routine (in mcode) just before xmas
and I never saw any responce to it. So I'm afraid most of you missed it
due to christmas holidays.  Is this true ? Should I repost it ?

bgribble@jarthur.Claremont.EDU (Bill Gribble) (01/25/91)

In article <kskalb.664747707@faui1f> kskalb@faui1f.informatik.uni-erlangen.de (Klaus Kalb) writes:

>Alonzo Gariepy says in his processor notes for the HP28 (at least in my copy)
>--> It is said that R4 is used by the interrupt handler, but I have yet to
>--> confirm it.

In an addendum to those notes he says that further investigation revealed 
  that this is not true.  You may use r4 as you wish.  

I missed your factorization posting, and would be interested in seeing, if
  not a repost, at least a description and location to get it.  Now seems
  like as good a time as any to ask for a list of important stuff that 
  transpired over break; jarthur is on a 2-day expire, so I missed *all*
  of it.  Don't repost articles, but I would think there's sufficient interest
  for one post describing all the docs and programs posted from Dec 15 or 
  so to Jan 20 or so, along with FTP locations and/or author addresses.

>-KK

*****************************************************************************
**   Bill Gribble                     Harvey Mudd College, Claremont, CA   **
**   bgribble@jarthur.claremont.edu   Never heard of it?  You're stupid.   **
*****************************************************************************

jpser@cup.portal.com (John Paul Serafin) (01/26/91)

I downloaded the integer factorization program and like it a lot.
John Serafin
jpser@cup.portal.com