View previous topic :: View next topic |
Author |
Message |
Guest
|
Complex struct... |
Posted: Sun Dec 20, 2009 1:46 am |
|
|
Hello
Is there any known problem using complex struct in 4.093?
Just a ex. not production code...
Code: |
struct {
struct {int18 a; int8 b; int1 c;}L;
struct {int18 a; int8 b; int1 c;}R;
struct {int18 a; int8 b; int1 c;}U;
struct {int18 a; int8 b; int1 c;}D;
}Master;
|
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Sun Dec 20, 2009 3:05 am |
|
|
Found this:
And I think it is frustration, _wakeup_ CCS! Waste time using this buggy thing.
Code: | #include "18F4550.h"
struct {
struct {int8 a; int16 b; int1 c;}S1;
struct {int8 a; int16 b; int1 c;}S2;
}Master;
void t1(){
Master.S1.A=0x12; //Make wrong assign
Master.S1.b=0x1234;
Master.S1.c=1;
Master.S2.A=0x13;//Make right assign
Master.S2.b=0x1234;
Master.S2.c=1;
}
void main(){
t1();
} |
Code: | .................... struct {
.................... struct {int8 a; int16 b; int1 c;}S1;
.................... struct {int8 a; int16 b; int1 c;}S2;
.................... }Master;
....................
.................... void t1(){
.................... Master.S1.A=0x12;
0004: MOVLW 12
0006: MOVWF Master
.................... Master.S1.b=0x1234; ERROR! Look at S2
0008: MOVWF Master+2
000A: MOVLW 34
000C: MOVWF Master+1
.................... Master.S1.c=1;
000E: BSF Master+3.0
....................
.................... Master.S2.A=0x13;
0010: MOVLW 13
0012: MOVWF Master+4
.................... Master.S2.b=0x1234; RIGHT
0014: MOVLW 12
0016: MOVWF Master+6
0018: MOVLW 34
001A: MOVWF Master+5
.................... Master.S2.c=1;
001C: BSF Master+7.0
....................
.................... }
001E: GOTO 0038 (RETURN)
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Dec 20, 2009 6:05 am |
|
|
The code shown is correct....
The point is in the first case, 'W' already contains '12', from the assign to S1.a, so the compiler saves an instruction, by not loading it again.
Code: |
0004: MOVLW 12
0006: MOVWF Master
.................... Master.S1.b=0x1234; ERROR! Look at S2
0008: MOVWF Master+2 //Here 'W' already contains 12, so this is put
//into the LSB of Master.S1.b
000A: MOVLW 34
000C: MOVWF Master+1
|
There is nothing wrong with the assignment as shown. So the question is 'what are you seeing that is not working'?.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Sun Dec 20, 2009 8:46 am |
|
|
Hello and thanks for the explanation.
I'am real sorry CCS! I complain too early.
The real problem was the late time last night, the problem is now solved. |
|
![](templates/subSilver/images/spacer.gif) |
|