OpenCores
no use no use 1/1 no use no use
Bug in hello-uart
by Unknown on Dec 30, 2004
Not available!
Hi!

I'm not sure, whether this is the right mailing list, but there is a
tricky bug in the hello-uart example program of or1k:

Index: hello-uart/reset.S
===================================================================
RCS file: /cvsroot/anonymous/or1k/hello-uart/reset.S,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 reset.S
--- hello-uart/reset.S 7 Jan 2004 10:51:11 -0000 1.1.1.1
+++ hello-uart/reset.S 30 Dec 2004 14:53:54 -0000
@@ -11,7 +11,7 @@
_reset:
l.movhi r1,hi(_stack-4)
l.ori r1,r1,lo(_stack-4)
- l.addi r2,r0,-3
+ l.addi r2,r0,-4
l.and r1,r1,r2

l.movhi r2,hi(_main)

I suppose that the -3 should do an alignment to 32bit words but this is
not the case. Because -3 is b1101 or 0xD so it should be -4 equal to
b1100 or 0xC. Could somebody please confirm this?

Regards,
Patrick
Bug in hello-uart
by Unknown on Dec 30, 2004
Not available!
Matjaz Breskvar schrieb:
_reset:
l.movhi r1,hi(_stack-4)
l.ori r1,r1,lo(_stack-4)
- l.addi r2,r0,-3
+ l.addi r2,r0,-4
l.and r1,r1,r2

l.movhi r2,hi(_main)
I suppose that the -3 should do an alignment to 32bit words but this is
not the case. Because -3 is b1101 or 0xD so it should be -4 equal to
b1100 or 0xC. Could somebody please confirm this?

it's readibility bug in any case. Since this is an example, let's do
it really clearly:

l.movhi r2,hi(0xfffffffc)
l.ori r2,lo(0xfffffffc)

and now there is no confusion anymore.


I found the example very usefull for my own start-up code, so I'm not
sure whether changing it to fixed addresses is a good idea, but I leave
it up to the maintainer ... ;-)

Regards,
Patrick

Bug in hello-uart
by Unknown on Dec 30, 2004
Not available!
This l.addi r2,r0,-4 and this l.movhi r2,hi(0xfffffffc) l.ori r2,lo(0xfffffffc) produces exactly the same result (r2). :-) regards, Damjan ----- Original Message ----- From: "Patrick Loschmidt" Patrick.Loschmidt@oeaw.ac.at> To: "List about OpenRISC project" openrisc@opencores.org> Sent: Thursday, December 30, 2004 4:36 PM Subject: Re: [openrisc] Bug in hello-uart
Matjaz Breskvar schrieb:
_reset:
l.movhi r1,hi(_stack-4)
l.ori r1,r1,lo(_stack-4)
- l.addi r2,r0,-3
+ l.addi r2,r0,-4
l.and r1,r1,r2

l.movhi r2,hi(_main)
I suppose that the -3 should do an alignment to 32bit words but this is
not the case. Because -3 is b1101 or 0xD so it should be -4 equal to
b1100 or 0xC. Could somebody please confirm this?

it's readibility bug in any case. Since this is an example, let's do
it really clearly:

l.movhi r2,hi(0xfffffffc)
l.ori r2,lo(0xfffffffc)

and now there is no confusion anymore.
I found the example very usefull for my own start-up code, so I'm not sure whether changing it to fixed addresses is a good idea, but I leave it up to the maintainer ... ;-) Regards, Patrick _______________________________________________ http://www.opencores.org/mailman/listinfo/openrisc



Bug in hello-uart
by Unknown on Dec 30, 2004
Not available!
Damjan Lampret schrieb:
This
>
l.addi r2,r0,-4
>
and this
l.movhi r2,hi(0xfffffffc)
l.ori r2,lo(0xfffffffc)
produces exactly the same result (r2). :-)


Sorry, my fault, I thought, he wanted to replace the l.movhi
r1,hi(_stack-4) ...

Regards,
Patrick

Bug in hello-uart
by Unknown on Dec 30, 2004
Not available!
* Patrick Loschmidt (Patrick.Loschmidt@oeaw.ac.at) wrote:
Hi!

I'm not sure, whether this is the right mailing list, but there is a
tricky bug in the hello-uart example program of or1k:


This is the right mailing list.

Index: hello-uart/reset.S
===================================================================
RCS file: /cvsroot/anonymous/or1k/hello-uart/reset.S,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 reset.S
--- hello-uart/reset.S 7 Jan 2004 10:51:11 -0000 1.1.1.1
+++ hello-uart/reset.S 30 Dec 2004 14:53:54 -0000
@@ -11,7 +11,7 @@
_reset:
l.movhi r1,hi(_stack-4)
l.ori r1,r1,lo(_stack-4)
- l.addi r2,r0,-3
+ l.addi r2,r0,-4
l.and r1,r1,r2

l.movhi r2,hi(_main)

I suppose that the -3 should do an alignment to 32bit words but this is
not the case. Because -3 is b1101 or 0xD so it should be -4 equal to
b1100 or 0xC. Could somebody please confirm this?


it's readibility bug in any case. Since this is an example, let's do
it really clearly:

l.movhi r2,hi(0xfffffffc)
l.ori r2,lo(0xfffffffc)

and now there is no confusion anymore.

regards,
p.

Bug in hello-uart
by Unknown on Dec 30, 2004
Not available!
* Patrick Loschmidt (Patrick.Loschmidt@oeaw.ac.at) wrote:
Matjaz Breskvar schrieb:
>_reset:
> l.movhi r1,hi(_stack-4)
> l.ori r1,r1,lo(_stack-4)
>- l.addi r2,r0,-3
>+ l.addi r2,r0,-4
> l.and r1,r1,r2
>
> l.movhi r2,hi(_main)
>I suppose that the -3 should do an alignment to 32bit words but this is
>not the case. Because -3 is b1101 or 0xD so it should be -4 equal to
>b1100 or 0xC. Could somebody please confirm this?

>it's readibility bug in any case. Since this is an example, let's do
>it really clearly:
>
>
>and now there is no confusion anymore.


I found the example very usefull for my own start-up code, so I'm not
sure whether changing it to fixed addresses is a good idea, but I leave
it up to the maintainer ... ;-)


ok. maybe my problem is that i'm looking at only this 5 lines
of code, but i really don't get 'the fixed addresses'...

as far as i can see (from this 5 lines of code, so i might see very wrong)
the purpose of the code is to load the pointer to the stack into r1. since
it may not be aligned to 0x4, we want to make sure it is. so
to shave off the last two bits we now load the complete mask in the r2
explicitly instead of the former shorter but kind of more difficult to see
l.addi line... the code would now be:

l.movhi r1,hi(_stack-4)
l.ori r1,r1,lo(_stack-4)
l.movhi r2,hi(0xfffffffc)
l.ori r2,lo(0xfffffffc)
l.and r1,r1,r2

why wouldn't this be ok ?

regards,
p.

no use no use 1/1 no use no use
© copyright 1999-2026 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.