



Can openrisc gcc exclude l.sb command in compile?
by hwmin75 on Feb 19, 2013 |
hwmin75
Posts: 20 Joined: Mar 8, 2010 Last seen: Jul 21, 2018 |
||
Hello.
Can openrisc gcc exclude l.sb command in compile? if possible, What options should I be used? Thank you. |
RE: Can openrisc gcc exclude l.sb command in compile?
by jeremybennett on Feb 19, 2013 |
jeremybennett
Posts: 815 Joined: May 29, 2008 Last seen: Jun 13, 2019 |
||
Hello.
Can openrisc gcc exclude l.sb command in compile? if possible, What options should I be used? Thank you. Hi hwmin75, No. The ability to store bytes efficiently is a core function. Why do you want to not use l.sb? Best wishes, Jeremy |
RE: Can openrisc gcc exclude l.sb command in compile?
by hwmin75 on Feb 19, 2013 |
hwmin75
Posts: 20 Joined: Mar 8, 2010 Last seen: Jul 21, 2018 |
||
We use union and bitfield of 'C' to write register of I/O device.
The below is example used. ------------------------------------------- ex) union device { ulong a; struct reg{ uint i:8; uint j:8; uint k:16; }; }; union device *temp = 0x90000000; temp->reg.j = 20; ------------------------------------ we found that temp->reg.j = 20 is changedcp into 'l.sb 0x1(r6) r4' by or32-elf-objdump and device bus is 32 bit wide.(r6 = 0x90000000, r4=20) and this situation made a error to write register. we wanted that l.sw should be used in this situation. Thank you. |
RE: Can openrisc gcc exclude l.sb command in compile?
by jeremybennett on Feb 20, 2013 |
jeremybennett
Posts: 815 Joined: May 29, 2008 Last seen: Jun 13, 2019 |
||
We use union and bitfield of 'C' to write register of I/O device. The below is example used. union device { ulong a; struct reg{ uint i:8; uint j:8; uint k:16; }; }; union device *temp = 0x90000000; temp->reg.j = 20; we found that temp->reg.j = 20 is changedcp into 'l.sb 0x1(r6) r4' by or32-elf-objdump and device bus is 32 bit wide.(r6 = 0x90000000, r4=20) and this situation made a error to write register. we wanted that l.sw should be used in this situation. Hi hwmin75, The problem is your C code, not the compiler! For a start if this is a device register you should be declaring it volatile. Then you've explicitly written just 8 bits in C. If you want a single 32-bit write, that is what you should do by writing to temp->a. This is not good C code. I presume you have ensured that "ulong" is 32-bits wide. Depending on how that type is declared it may not be the case. It seems to me you want two copies of this struct, one to set up your data (using the "reg" fields) and one volatile, which you read and write using the "a" field. HTH Jeremy
-- |



