Unknown
Jan 05, 2005, 09:09 AM
High Level Programming languages like C++ and Java are interpreted, which means that the compiler has to translate the code in your program to machine language before your program can be executed. Much closer to machine language is assembly code, which some programmers prefer because it allows you to code faster programs. Here's a comparison:
void crcgen( void )
{
unsigned long crc, poly;
int i, j;
poly = 0xEDB88320L;
for (i=0; i<256; i++) {
crc = i;
for (j=8; j>0; j--) {
if (crc&1) {
crc = (crc >> 1) ^ poly;
} else {
crc >>= 1;
}
}
crcTable[i] = crc;
}
}
And now this is assembly:
procedure crcgen;
asm
mov ebx,$EDB88320
mov edi,offset crctbl
xor ecx,ecx
@s0:
mov eax,ecx
mov edx,8
@e0:
test eax,1
jz @n1
shr eax,1
xor eax,ebx
jmp @e1
@n1:
shr eax,1
@e1:
dec edx
jnz @e0
stosd
inc ecx
cmp ecx,256
jb @s0
end;
Rick
Jan 05, 2005, 01:24 PM
So which one has the bug?