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

ccs vs picc

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



Joined: 14 Jan 2004
Posts: 9
Location: Xiamen,Fujian Province, China

View user's profile Send private message Send e-mail ICQ Number

ccs vs picc
PostPosted: Fri Dec 02, 2005 12:17 am     Reply with quote

picc:

#include <pic.h>

__CONFIG(HS&PWRTEN&WDTEN&BOREN&LVPDIS);

#define int8 unsigned char
#define int16 unsigned int


void main()
{
int8 temp1=0,temp2=0;
int16 temp=0,T=0;
while(1)
{
temp1=1;
temp2=2;

*(int8 *)&temp=temp1;
*((int8 *)&temp+1)=temp2;
T=temp;

// temp=make16(temp1,temp2);

}

}

picc:

*(int8 *)&temp=temp1;
*((int8 *)&temp+1)=temp2;

汇编为:
movf temp1,w
movwf temp
movf temp2,w
movwf 0x23

temp 为0x22.0x23
4条指令





-----------------------
ccs的:3.187
#include <16F877A.h>
//#use delay(clock=20000000)
//#fuses NOWDT,HS, NOPROTECT,NOLVP

void main()
{
int8 temp1=0,temp2=0;
int16 temp=0,T=0;
while(1)
{
temp1=1;
temp2=2;

*(int8 *)&temp=temp1;
*((int8 *)&temp+1)=temp2;
T=temp;

//temp=make16(temp2,temp1);

}

}
.................... *(int8 *)&temp=temp1;
0017: MOVLW temp
0018: MOVWF FSR
0019: MOVF temp1,W
001A: MOVWF INDF
.................... *((int8 *)&temp+1)=temp2;
001B: MOVLW temp+1
001C: MOVWF FSR
001D: MOVF temp2,W
001E: MOVWF INDF

.................... temp=make16(temp2,temp1);
0023: MOVF temp2,W
0024: MOVWF temp+1
0025: MOVF temp1,W
0026: MOVWF temp


-----------
_________________
Lan Yong
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