Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Awful x86 asm code

Name: Anonymous 2011-06-28 19:45

xor ebx, ebx //Start the cycle counter at 0
mov ecx, 3   //Put 3 into ecx for multiplication
Parity:
cmp eax, 1   //Are we done yet?
je Done      //If so, go to the end
mov edx, eax //edx = eax
and edx, 1   //Get parity bit
cmp edx, 0   //Is it even?
je ParEven   //If so, skip straight to that part
//eax is odd here
mul ecx      //treble eax (ecx is just 3)
add eax, 1   //and +1
add ebx, 1   //increment cycle counter
//eax is now even, so flow straight into even handler
ParEven:
shr eax, 1   //divide by two
add ebx, 1   //increment cycle counter
jmp Parity   //time to test parity again


http://everything2.com/title/Hailstone+number+sequence

Name: Anonymous 2011-06-29 7:33

Not only is it awful, it also doesn't work.

EAX is not initialized.
Label "Done" is undefined.

Assuming most compilers produce reasonably valid code, this is another clue that points towards a human programmer.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List