Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!snorkelwacker.mit.edu!ai-lab!rice-chex!bson From: bson@rice-chex.ai.mit.edu (Jan Brittenson) Newsgroups: comp.sys.handhelds Subject: Re: Chip question Message-ID: <12400@life.ai.mit.edu> Date: 13 Dec 90 12:03:22 GMT References: Sender: news@ai.mit.edu Organization: nil Lines: 75 In article TNAN0@CCVAX.IASTATE.EDU writes: > I've been trying to write some stand alone (non-RPL-stack dependent) > programs... What's the best way to locate and access relative memory > addresses? For example, if I have a data area at the beginning of my > code, it seems to me the best way to access it would be to use a > thisone move.a pc,a" followed by a "move.p5 thisone-dataarea,c" > sub.a c,a" thus leaving the address STAR 1.02.3 and later comes with a macro ADDR in hp48.star. The macro is used as follows: ADDR location, dest Where `location' is any expression and `dest' is either C, A, D0, or D1. An example: ; ... addr foo, c ; ... foo: ascii `Hello world!' The code generated is much what you describe, although ADD is used instead of SUB. A.a is used for temporary storage, unless the destination is A, in which case C.a is used as a temporary register. The macro can easily be modified to take an optional third argument to specify which register to use for temporary storage. For the insanely curious, I'll include the macro definition. -- Jan Brittenson bson@ai.mit.edu macro addr operand, dest save sym sym = gensym save tmp save ntmp dest = uc^`$dest' if `$dest' == `A' tmp = `C' ntmp= `A' else tmp = `A' ntmp= `C' endif move pc, $tmp $sym = . if (`$dest' == `D0') || (`$dest' == `D1') move.5 ($operand)-$sym, $dest swap $ntmp, $dest add.a $tmp, $ntmp swap $ntmp, $dest else move.p5 ($operand)-$sym, $dest add.a $tmp, $dest endif restore tmp restore ntmp restore sym endmacro