CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Complex struct...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Complex struct...
PostPosted: Sun Dec 20, 2009 1:46 am     Reply with quote

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;
Guest








PostPosted: Sun Dec 20, 2009 3:05 am     Reply with quote

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)
Ttelmah
Guest







PostPosted: Sun Dec 20, 2009 6:05 am     Reply with quote

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
Guest








PostPosted: Sun Dec 20, 2009 8:46 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group