- 论坛徽章:
- 0
|
下面是一个用于CRC校验的程序,内嵌汇编语句,请问大家应该用什么编译器编译,tc2。0可以吗,我试了试,结果不认汇编语句?
#include <stdio.h>;
void a_byte_to_crc(unsigned char onebyte, unsigned int *crc_reg)
{
unsigned int wd;
wd = *crc_reg;
asm{
MOV AL,onebyte;
MOV CH,AL;
MOV CL,8;
}
lop:
asm{
RCL CH,1;
JMP crc_gen;
}
rtnds:
arm{
DEC CL;
JNZ lop;
JMP end;
}
crc_gen:
arm{
MOV AX,wd;
RCR AX,1;
RCL AX,1;
CLC;
JNO cnt;
XOR AX,0x0810;
STC;
}
cnt:
arm{
RCL AX,l;
MOV wd,AX;
JMP rtnd;
}
end:
*crc_reg = wd;
}
void main(int argc, char *argv[])
{
FILE *fp;
signed int c;
long unsigned int i = 0;
unsigned int crc = 0xffff;
puts("Cyclic Redundancy Check Program" ;
if(argc==1)
puts("Usage:CRC<filename>;" ;
else{
fp = fopen(argv[1],"rb" ;
if(fp==NULL)
puts("Cant open iput file" ;
else{
while((c = getc(fp))!=EOF){
a_byte_to_crc(c,&crc);
i++;
}
printf("CRC=%#X File length = %lu", crc, i);
fclose(fp);
}
}
} |
|