本帖最后由 matthewchan 于 2016-3-12 14:41 编辑
近来在用C语言来写一个高进度超长位数的算术函数,包括加减乘数。
测试平台是PIC16,发现了不少编译器的bug。。。。浪费了不少时间。。。。
首先用mplab 8.x +picc9.65 编译的代码:一个简单的数组访问,居然出错了。
一时间找不到别的PICC了,只能放弃PICC了,转向XC8.
然后继续写代码:
typedef struct
{
unsigned char *value; //this value restrict the max of the input and result.
unsigned char integer_bit;
unsigned char frac_bit;
unsigned char isnegetive:1;
//just help for cpmpute
unsigned char iscomplement:1;
}mytype;
编译:result->isnegetive = ina->isnegetive 的时候
用XC8 1.30 :又错了
1233 ;calc.c: 92: result->isnegetive = ina->isnegetive;
1234 006E 0843 movf add@ina,w
1235 006F 3E03 addlw 3
1236 0070 0084 movwf 4
1237 0071 1003 clrc
1238 0072 1800 btfsc 0,0
1239 0073 1403 setc
1240 0074 0838 movf add@result,w
1241 0075 3E03 addlw 3
1242 0076 0084 movwf 4
1243 0077 1000 bcf 0,0
1244 0078 1803 btfsc 3,0
1245 0079 1400 bsf 0,0
用XC8 1.36 free模式编译,对了
1235 ;calc.c: 92: result->isnegetive = ina->isnegetive;
1236 0074 0843 movf add@ina,w
1237 0075 3E03 addlw 3
1238 0076 0084 movwf 4
1239 0077 0800 movf 0,w
1240 0078 00B9 movwf ??_add
1241 0079 0838 movf add@result,w
1242 007A 3E03 addlw 3
1243 007B 0084 movwf 4
1244 007C 1000 bcf 0,0
1245 007D 1839 btfsc ??_add,0
1246 007E 1400 bsf 0,0
|