8queens icon indicating copy to clipboard operation
8queens copied to clipboard

FreeBSD support

Open iamgreaser opened this issue 11 years ago • 0 comments

I'm not sure how to sort out the nasm autoinstall crap, so I just ran this instead:

nasm 8queens.asm -o 8queens.o -f elf64 && ld -o 8queens 8queens.o

Anyway, the syscalls are different. FreeBSD uses 1 for exit, and 4 for write. Calling convention for 64-bit x86 is identical to Linux, or at least close enough for 8queens to work.

Do not be an idiot like I was and blindly go "ok, 2 means write". It means fork. Yeah, I accidentally forkbombed myself. Fortunately, the process limit was reached and it stopped, or something like that.

With that said, support should be pretty easy.

EDIT: Also, exit() appears to return something else. rdi is the correct register, but it appears that r8 is getting mangled somewhere.

EDIT 2: -DNOPRETTY returns the correct value of 92. push r8/pop r8 around the write() syscalls results in values which are randomly larger, about 105 or something.

iamgreaser avatar Feb 26 '14 09:02 iamgreaser