|
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
-----------
看来picc在它的指针方面有它独到的地方了。结合指针,用picc有可能可以写出汇编级别的代码了. |
|