Help - Search - Members - Calendar
Full Version: Assembly Language versus Higher Level Programming Languages
BrainMeta.com Forum > Science > Computer Science & Coding > Assembly, C\C++
Unknown

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
So which one has the bug?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.


Home     |     About     |    Research     |    Forum     |    Feedback  


Copyright © BrainMeta. All rights reserved.
Terms of Use  |  Last Modified Tue Jan 17 2006 12:39 am