* ppc assembler help needed
@ 2000-05-15 15:54 Andreas Tobler
2000-05-15 16:08 ` Franz Sirl
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Tobler @ 2000-05-15 15:54 UTC (permalink / raw)
To: Linux -Dev
Hi,
I have some problems understanding the following code snippet. It is
from misc.S in kernel 2.3.
The function call is like this:
void _insl_ns(volatile u32 *port, u32 *buf, int nl)
_GLOBAL(_insl_ns)
cmpw 0,r5,0
mtctr r5
subi r4,r4,4
blelr-
00: lwz r5,0(r3)
eieio
stwu r5,4(r4)
bdnz 00b
blr
Am I right with port = r3, buf = r4, nl = r5?
If so, cmpw 0,r5,0 compares the content of r5, in my case nl, with zero
and stores the result in CR0?
What does blelr- exactly do? 'branch if less than or equal' according to
the 'Programming Environment for 32bit uPs' from Motorola.
Commenting out the cmpw and the blelr- line as in kernel-2.2, then the
function works. The values from nl are in the range from 10 to 20 (int).
So the the blelr- shouldn't happen.
The function in C looks a bit like: (Thanks to Paul)
void _insl_ns(volatile u32 *port, u32 *buf, int nl)
{
if (nl <= 0)
return;
do {
*buf++ = *port;
eieio();
} while (--nl != 0);
}
Thanks for any explanation
Andreas
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: ppc assembler help needed
2000-05-15 15:54 ppc assembler help needed Andreas Tobler
@ 2000-05-15 16:08 ` Franz Sirl
2000-05-15 18:26 ` Andreas Tobler
0 siblings, 1 reply; 4+ messages in thread
From: Franz Sirl @ 2000-05-15 16:08 UTC (permalink / raw)
To: toa; +Cc: Linux -Dev
At 17:54 15.05.00, Andreas Tobler wrote:
>Hi,
>
>I have some problems understanding the following code snippet. It is
>from misc.S in kernel 2.3.
>
>The function call is like this:
>
>void _insl_ns(volatile u32 *port, u32 *buf, int nl)
>
>_GLOBAL(_insl_ns)
> cmpw 0,r5,0
> mtctr r5
> subi r4,r4,4
> blelr-
>00: lwz r5,0(r3)
> eieio
> stwu r5,4(r4)
> bdnz 00b
> blr
>
>Am I right with port = r3, buf = r4, nl = r5?
>If so, cmpw 0,r5,0 compares the content of r5, in my case nl, with zero
>and stores the result in CR0?
No, cmpw 0,r5,0 compares r5 to r0, use cmpwi 0,r5,0 to make a signed
compare of r5 against 0
Franz.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ppc assembler help needed
2000-05-15 16:08 ` Franz Sirl
@ 2000-05-15 18:26 ` Andreas Tobler
2000-05-15 18:26 ` David Edelsohn
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Tobler @ 2000-05-15 18:26 UTC (permalink / raw)
To: Franz Sirl; +Cc: Linux-Dev
Hoi Franz,
Franz Sirl wrote:
> No, cmpw 0,r5,0 compares r5 to r0, use cmpwi 0,r5,0 to make a signed
> compare of r5 against 0
This works, thanks. The next question is automatically in the queue:
all functions, insX/outsX in misc.S use this cmpw 0,r5,0, shouldn't it
be a cmpwi 0,r5,0 then?
Thanks,
Andreas
BTW, does it mind which CPU is behind? In my case it's a 601.
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ppc assembler help needed
2000-05-15 18:26 ` Andreas Tobler
@ 2000-05-15 18:26 ` David Edelsohn
0 siblings, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2000-05-15 18:26 UTC (permalink / raw)
To: toa; +Cc: Franz Sirl, Linux-Dev
>>>>> Andreas Tobler writes:
Andreas> Franz Sirl wrote:
>> No, cmpw 0,r5,0 compares r5 to r0, use cmpwi 0,r5,0 to make a signed
>> compare of r5 against 0
Andreas> This works, thanks. The next question is automatically in the queue:
Andreas> all functions, insX/outsX in misc.S use this cmpw 0,r5,0, shouldn't it
Andreas> be a cmpwi 0,r5,0 then?
Presumably all of the assembly functions want to compare against
an immediate value and should use cmpwi.
Andreas> BTW, does it mind which CPU is behind? In my case it's a 601.
cmpwi is valid for all PowerPC processors, including 601.
David
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2000-05-15 18:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-05-15 15:54 ppc assembler help needed Andreas Tobler
2000-05-15 16:08 ` Franz Sirl
2000-05-15 18:26 ` Andreas Tobler
2000-05-15 18:26 ` David Edelsohn
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).