本帖最后由 lvben5d 于 2022-11-24 09:06 编辑
typedef unsigned char u8;
typedef unsigned short int u16;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int u32; //注意 因为是8位机 这里不是4个字节了!!
typedef unsigned long ul32; //这个才是4字节!!
u16 C[8]={0,0,0,0,0};
u16 D[8]={100000,65534,3,4,5}; //这里100000 大于65535 溢出了,但是编译器不会报错~ 自己要注意数值范围
void f(u16 *p)
{
u8 i;
for(i=0; i<8; i++) C = *p++ ;
}
2. kF8 编译器支持的 结构体成员变量 占内存不能超过128字节,否则就报错! 估计是硬件内存分页引起!
typedef struct{
u8 key[8]; //Byte N of Secret; Secret Begins at Address 80h (see Figure 5)
u8 _PP[32]; //Byte N of Memory Page; Memory Pages begin at 00h, 20h, 40h and 60h (see Figure 5)
u8 _SP[8]; //Byte N of Scratchpad
u8 _MP; //MP[7:3] = 00000b, MP[2:0] = T[7:5]
u8 _RN[8]; //Byte N of Registration Number. The CRC byte of the registration number is not used.
}SHA1Para_t;
typedef struct
{
ul32 _M[17];
ul32 _H[5];
}SHA1Para2_t;
原本是这样
/* sha1参数 */
typedef struct
{
uint8_t _SS[8]; //Byte N of Secret; Secret Begins at Address 80h (see Figure 5)
uint8_t _PP[32]; //Byte N of Memory Page; Memory Pages begin at 00h, 20h, 40h and 60h (see Figure 5)
uint8_t _SP[8]; //Byte N of Scratchpad
uint8_t _MP; //MP[7:3] = 00000b, MP[2:0] = T[7:5]
uint8_t _RN[8]; //Byte N of Registration Number. The CRC byte of the registration number is not used.
uint32_t _M[17];
uint32_t _H[5];
}SHA1Para_t; 这里超过了128字节 编译就不过!!!!
|