On May 11, 4:41 am, Borenard <meuld...@[EMAIL PROTECTED]
> wrote:
> Hi,
> I'd like to know what the arguments of the system call SYS_read are,
> in PPC assembly, to read in some typed characters from the terminal.
> r0=3 to call sys_read
> r3=1 for stdin
> Where does the pointer go that indicates where the typed string is
> stored?
> For sys_write this is r4 and r5, but I don't seem to get chars back
> if
> I use r4 and r5 with sys_read.
> Regards,
> Borenard
Typically, you will expect return value in 3. This is true for ppc64
linux, syscalls in this regard appear to somewhat follow the AIX /
Open ABI. Incidentally I have had no problems with syscalls on ppc64
linux.
http://www.ibm.com/developerworks/linux/library/l-powasm4.html
(remember this describes the C ABI and syscalls may not necessarily
need to stick to these. Fortunately when in doubt, linux source code
is quite easily available)
Whether it is true on the ppc32 mac OSX I do not know. I've no
experience to speak of.
For a simple call like that one would imagine 3 will contain the
return value.
This is the Apple ABI link.
http://developer.apple.com/do***entation/DeveloperTools/Conceptual/LowLevelABI/Articles/64bitPowerPC.html#//apple_ref/doc/uid/TP40002471-SW14
On IA-32 OS X syscalls read pretty much behaved like the linux one.
Expected return value in EAX.
BUT fork didn't. (Long story see the other post). And lseek didn't.
And neither did creat (missing) nor open.
I will tell you for a fact that I have been warned by at least one
Apple guy on the kernel mailing list (thanks) NOT to do syscalls on OS
X, and there is great wisdom in this. Try not to do syscalls. If you
must, just be prepared for a world of hurt. The standard advice is to
link to c.
I have to tell you I have had a lot of 'fun' (/sarcasm) ****ting IA-32
asm over to OS X - unpredictable behaviour etc (by this I mean
behaviour deviating from expected based on linux code). I went ahead
and did it anyway but I warn you I am by nature a little bloody
minded.
Robert Spykerman


|