Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!otter.hpl.hp.com!hpltoad!cdollin!kers From: kers@hplb.hpl.hp.com (Chris Dollin) Newsgroups: comp.sys.acorn Subject: Re: 32bit immediate load in ARM code Message-ID: Date: 17 May 91 07:23:38 GMT References: <+|Q_L||@warwick.ac.uk> Sender: news@hplb.hpl.hp.com (Usenet News Administrator) Organization: Hewlett-Packard Laboratories, Bristol, UK. Lines: 52 In-Reply-To: csuwr@warwick.ac.uk's message of 16 May 91 05:35:57 GMT Nntp-Posting-Host: cdollin.hpl.hp.com Derek Hunter gives a cunning trick for loading far globals and big constants: You can do Ldr Rn,VERY_FAR_AWAY ; with: Ldr Rn,[PC] Ldr Rn,[PC,Rn] DCD VERY_FAR_AWAY-P% ; if V_F_A preceeds this code I'd generate LDR Rn, nnn[PC] (or however the s*d assembler notates it) LDR Rm, mmm[Rn] where nnn[PC] holds a pointer to the item you need. Of course this item is reusable for each far reference (so long as you stay ``near enough'' in the code). It's not relocatable; if it were, you'd have to do LDR Rm,[PC,Rn] as Derek does. However, if you *can* get away with fixed (or self-updating) code, then the former method allows you to group far globals together and access them using the one pointer (perhaps one per procedure). Derek adds: 32 bit immediate constants can be read with Ldr Rn,[PC] Bic Rn,Rn,# (( number >> 28 ) EOR 15) << 28 DCD number OR &F0000000 I'd definitely use an out-of-line constant in a table at the procedure head. It reduces the code to one instruction at the cost of a store reference (which I think Derek's costs in any case, but I'm not familiar enough with the timing details), and the constant is sharable. Of course, if you're prepared to spend 3 instructions on building the constant, then anything composable from 3 8-bit fields can be done by: MOV Rn, #XXX OR Rn, Rn, #YYY OR Rn, Rn, #ZZZ with XXX, YYY, ZZZ being suitable components of the full value. Do Acorn's object formats permit this to be expressed when the full value is some constant not known until link time? -- Regards, Kers. | "You're better off not dreaming of the things to come; Caravan: | Dreams are always ending far too soon."