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

ASM Segmentation Fault

Name: Anonymous 2013-10-30 12:27

Hey /prog/rammers,

I try to do a comparison between two strings, but I get a Segmentation Fault, can you guys help me to find the problem ?
Here is the code : http://pastebin.com/Ji2VGH6N

Thank you in advance.

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2013-10-31 10:34

Are you comparing two int* or char*? The C is for char, the code you wrote is for weirdly aligned ints.

Either way, that's way too many instructions...

pop edx
pop esi
pop edi
pop ecx
push ecx
repnz cmpsb  ; replace with cmpsd if you want to compare ints
pop eax
sub eax, ecx
push ecx
push eax
fild [esp]
pop eax
fild [esp]
pop eax
fdiv
jmp edx


(Untested. Written off-the-cuff.)

Name: Anonymous 2013-10-31 20:45

Why do you need floating point division to compare strings? x86 is a heaping pile of shit, but string comparison is at least one hoop you don't have to jump through. It has rep cmpsb and family, which is pretty convenient.

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