* PPC 405 Register Model @ 2001-10-30 17:58 Jim Duey 2001-10-30 18:54 ` Jerry Van Baren 2001-10-30 20:31 ` Frank Rowand 0 siblings, 2 replies; 6+ messages in thread From: Jim Duey @ 2001-10-30 17:58 UTC (permalink / raw) To: linuxppc-embedded I'm needing to do some inline assembly for the Walnut board running MVista's Hard Hat Linux and I'm concerned about clobbering registers. Can someone point me to docs or source code that describes the register usage of HHL on the 405GP? Thanks, ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PPC 405 Register Model 2001-10-30 17:58 PPC 405 Register Model Jim Duey @ 2001-10-30 18:54 ` Jerry Van Baren 2001-10-30 20:31 ` Frank Rowand 1 sibling, 0 replies; 6+ messages in thread From: Jerry Van Baren @ 2001-10-30 18:54 UTC (permalink / raw) To: linuxppc-embedded It's in the specs ABI/EABI ([Embedded] Application Binary Interface). All compilers I have run across support EABI by default. http://www.esofta.com/softspecs.html gvb At 11:58 AM 10/30/01 -0600, you wrote: >I'm needing to do some inline assembly for the Walnut board running MVista's >Hard Hat Linux and I'm concerned about clobbering registers. Can someone >point me to docs or source code that describes the register usage of HHL on >the 405GP? > >Thanks, > ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PPC 405 Register Model 2001-10-30 17:58 PPC 405 Register Model Jim Duey 2001-10-30 18:54 ` Jerry Van Baren @ 2001-10-30 20:31 ` Frank Rowand 2001-10-30 19:54 ` Scott Anderson 1 sibling, 1 reply; 6+ messages in thread From: Frank Rowand @ 2001-10-30 20:31 UTC (permalink / raw) To: Jim Duey; +Cc: linuxppc-embedded Jim Duey wrote: > > I'm needing to do some inline assembly for the Walnut board running MVista's > Hard Hat Linux and I'm concerned about clobbering registers. Can someone > point me to docs or source code that describes the register usage of HHL on > the 405GP? If you use variable names instead of hard coding register numbers you don't have to worry about clobbering registers. For example, look at include/asm-ppc/atomic.h and you can find documentation of inline assembly at: http://gcc.gnu.org/onlinedocs/gcc-2.95.2/gcc_4.html#SEC93 -Frank -- Frank Rowand <frank_rowand@mvista.com> MontaVista Software, Inc ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PPC 405 Register Model 2001-10-30 20:31 ` Frank Rowand @ 2001-10-30 19:54 ` Scott Anderson 2001-10-30 20:53 ` Peter Barada 0 siblings, 1 reply; 6+ messages in thread From: Scott Anderson @ 2001-10-30 19:54 UTC (permalink / raw) To: frowand; +Cc: Jim Duey, linuxppc-embedded Frank Rowand wrote: > > Jim Duey wrote: > > > > I'm needing to do some inline assembly for the Walnut board running MVista's > > Hard Hat Linux and I'm concerned about clobbering registers. Can someone > > point me to docs or source code that describes the register usage of HHL on > > the 405GP? > > If you use variable names instead of hard coding register numbers you > don't have to worry about clobbering registers. FYI, I've seen gcc pass r0 as the register that a variable gets stored in. Because some PPC instructions treat r0 as a literal zero instead of the value in r0, this can be bad. To work around this, you just need to tell gcc that the asm uses r0 and it won't pass you a parameter in it. Here's an example chunk of code: /* Get the Time Base. Make sure that r0 is declared as used; * otherwise it can be passed to me as %0 which doesn't work * very well with stw. */ asm volatile ("0:; mftbu 3; mftb 4; mftbu 0; cmpw 3,0; bne 0b; " "stw 3,0(%0); stw 4,4(%0)" :: "r" (&tb): "r3", "r4", "r0"); The "r0" at the tail end of the asm tells gcc that r0 is used. Scott Anderson scott_anderson@mvista.com MontaVista Software Inc. (408)328-9214 1237 East Arques Ave. http://www.mvista.com Sunnyvale, CA 94085 ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: PPC 405 Register Model 2001-10-30 19:54 ` Scott Anderson @ 2001-10-30 20:53 ` Peter Barada 0 siblings, 0 replies; 6+ messages in thread From: Peter Barada @ 2001-10-30 20:53 UTC (permalink / raw) To: scott_anderson; +Cc: frowand, jduey, linuxppc-embedded >FYI, I've seen gcc pass r0 as the register that a variable gets stored >in. Because some PPC instructions treat r0 as a literal zero instead of >the value in r0, this can be bad. To work around this, you just need >to tell gcc that the asm uses r0 and it won't pass you a parameter in >it. Here's an example chunk of code: > > > /* Get the Time Base. Make sure that r0 is declared as used; > * otherwise it can be passed to me as %0 which doesn't work > * very well with stw. > */ > asm volatile ("0:; mftbu 3; mftb 4; mftbu 0; cmpw 3,0; bne 0b; " > "stw 3,0(%0); stw 4,4(%0)" > :: "r" (&tb): "r3", "r4", "r0"); > >The "r0" at the tail end of the asm tells gcc that r0 is used. 1) You use r0 as a temporary value, so you have to tell gcc that r0 is being clobbered. 2) You specified that &tb can be placed in a "r" register class which includes r0. If you change the register class to "b", then &tb would select any register that can be used as a base address, which is any general register *except* r0. 3) Since you are modifying the value in memory at the address contained in tb, you should add "memory" to the clobber list so the compiler won't assume that any memory values cached in registers are valid. You could rewrite this asm statement as: { unsigned int tmp1, tmp2, tmp3; asm volatile("0:; mtfbu %0; mtfb %1; mtfb %2; cmp %0,%2; bne 0b; " "stw %0,0(%4); stw %1,4(%4)" : "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3) : "b" (&tb) : "memory"); } All the output operands (tmp1/2/3) need to have "=" in the descriptor to indicate that they are output values, and also need "&" to indicate that they can not be shared with the intput value since these are clobbered in the asm template before the input operand is consumed. -- Peter Barada Peter.Barada@motorola.com Wizard 781-852-2768 (direct) WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax) ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* PPC 405 Register Model @ 2001-10-30 19:40 Jim Duey 0 siblings, 0 replies; 6+ messages in thread From: Jim Duey @ 2001-10-30 19:40 UTC (permalink / raw) To: linuxppc-embedded Thanks for all the responses Jim ** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/ ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2001-10-30 20:53 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2001-10-30 17:58 PPC 405 Register Model Jim Duey 2001-10-30 18:54 ` Jerry Van Baren 2001-10-30 20:31 ` Frank Rowand 2001-10-30 19:54 ` Scott Anderson 2001-10-30 20:53 ` Peter Barada -- strict thread matches above, loose matches on Subject: below -- 2001-10-30 19:40 Jim Duey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).