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

Pages: 1-

More assembly excitement

Name: Anonymous 2011-11-18 19:24

Sup /prau/g, I posted many moons ago about assembly and syscall and such. I've written a shitty compiler for some bullshit language I invented, it was awful. I'm now writing a much better C-compiler, and I am testing it out on Macs.

Now gather round, denizens, for I have a tale for you.
It was a cool February evening when I approached /prong/, asking for help about int 80h vs syscall. Now, ungrateful and unremorseful, I entered prog once more, much not dissimilar to the way I entered a sock earlier.

I ask this of you, strange anime creatures of these realms:

Linux

; various syscall setup
syscall
cmp rax, -1
jle .err
ret
.err:
neg rax
mov [errno], rax


FreeBSD

; various syscall setup
syscall
jc .err ; FreeBSD sets the carry flag on syscall errors, errno is in rax
ret
.err:
mov [errno], rax


Unfortunately, the FreeBSD-carry-style seems to work with Mach kernels, but I am unsure how I can get the error number: rax contains 4096, every time.
Help me /prog/, you're my only hope

Name: Anonymous 2011-11-19 2:20

FreeBSD sets the carry flag on syscall errors

well that's clever.

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2011-11-19 4:12

>>2
DOS used that convention too.

Made for nice "jc err" handling.

contains 4096, every time
Have you tried tracing through the kernel source to see where it gets set to 4096?

Name: Anonymous 2011-11-19 4:26

>>1
OSX/Darwin is based off of the Mach kernel, so have a look at how Mach does syscall (GNU Hurd uses the Mach design, so that might be a place to start).

Name: Anonymous 2011-11-19 12:04

Turns out I had a compiler bug, which wasn't reading errno, but the address of errno, hence the seemingly constant 4096 (which I was printing out, otherwise I would've noticed it looking more like an address).

I hope you all learn from my mistakes.

Name: Anonymous 2011-11-19 12:54

>>5
We'll take heed. Thank you for the update.

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