Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Programmer Help > Re: What are th...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 3736 of 3840
Post > Topic >>

Re: What are the arguments of SYS_read in PPC assembly?

by Robert Spykerman <robert.spykerman@[EMAIL PROTECTED] > May 10, 2008 at 04:38 PM

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
 




 5 Posts in Topic:
What are the arguments of SYS_read in PPC assembly?
Borenard <meuldijk@[EM  2008-05-10 11:41:36 
Re: What are the arguments of SYS_read in PPC assembly?
Robert Spykerman <robe  2008-05-10 16:38:41 
Re: What are the arguments of SYS_read in PPC assembly?
Robert Spykerman <robe  2008-05-10 17:37:59 
Re: What are the arguments of SYS_read in PPC assembly?
Robert Spykerman <robe  2008-05-10 18:02:06 
Re: What are the arguments of SYS_read in PPC assembly?
Borenard <meuldijk@[EM  2008-05-14 06:31:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 0:30:48 CDT 2008.