Re: [osol-code] independent write function in assembly language

2007-04-11 Thread Adam Zhang
Frank, thanks for clarification of the calling convention between common function and system call. /adam Frank Hofmann wrote: On Wed, 11 Apr 2007, Adam Zhang wrote: Hi Oliver, Yes. the code was running on Linux. Thank you very much for the correction. You are right. i just check the AMD64

Re: [osol-code] independent write function in assembly language

2007-04-11 Thread Oliver Yang
Frank Hofmann wrote: But do you know where i can find the x86 ABI that Solaris uses? You might've noticed that neither the AMD64 ABI nor the i386 ABI anywhere mention the system call mechanism (apart from the _exit special case in the i386 ABI, where it says you can 'lcall 7, $0'). It is d

Re: [osol-code] independent write function in assembly language

2007-04-11 Thread Frank Hofmann
On Wed, 11 Apr 2007, Adam Zhang wrote: Hi Oliver, Yes. the code was running on Linux. Thank you very much for the correction. You are right. i just check the AMD64 ABI (http://www.x86-64.org/documentation.html) that Solaris conforms to. Because the parameter I need transfer is char array, it

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Oliver Yang
Adam Zhang wrote: Hi Oliver, Yes. the code was running on Linux. Thank you very much for the correction. You are right. i just check the AMD64 ABI (http://www.x86-64.org/documentation.html) that Solaris conforms to. Because the parameter I need transfer is char array, it needs to be put in

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Adam Zhang
Hi Oliver, Yes. the code was running on Linux. Thank you very much for the correction. You are right. i just check the AMD64 ABI (http://www.x86-64.org/documentation.html) that Solaris conforms to. Because the parameter I need transfer is char array, it needs to be put in the stack during th

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Oliver Yang
Oliver Yang wrote: Adam Zhang wrote: Hi all, i just write an independent write function in assembly language to write a string to stderr. But the code doesn't work on Solaris. It seems you are using Gcc inline asm which will generate a system call by issuing "int 0x91". But you should kno

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Casper . Dik
>On 4/10/07, Frank Hofmann <[EMAIL PROTECTED]> wrote: >> But then, >> what's the advantage of non-portable hacks like the above versus: >> >> void write_stderr ( char * buf, int n ) >> { >> (void)write(fileno(stderr), buf, n); >> } >> >> Why can you not have the library call ? > >The usual

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Darren J Moffat
Paul Durrant wrote: On 4/10/07, Frank Hofmann <[EMAIL PROTECTED]> wrote: But then, what's the advantage of non-portable hacks like the above versus: void write_stderr ( char * buf, int n ) { (void)write(fileno(stderr), buf, n); } Why can you not have the library call ? The usual reas

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Paul Durrant
On 4/10/07, Frank Hofmann <[EMAIL PROTECTED]> wrote: But then, what's the advantage of non-portable hacks like the above versus: void write_stderr ( char * buf, int n ) { (void)write(fileno(stderr), buf, n); } Why can you not have the library call ? The usual reason is to avoid an LD_

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Frank Hofmann
On Tue, 10 Apr 2007, Paul Durrant wrote: On 4/10/07, Adam Zhang <[EMAIL PROTECTED]> wrote: i just write an independent write function in assembly language to write a string to stderr. But the code doesn't work on Solaris. Below is the code: void write_stderr ( char * buf, int n ) { int bl

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Oliver Yang
Adam Zhang wrote: Hi all, i just write an independent write function in assembly language to write a string to stderr. But the code doesn't work on Solaris. It seems you are using Gcc inline asm which will generate a system call by issuing "int 0x91". But you should know, doesn't like Linu

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Adam Zhang
Thanks paul for your input. I tested on 32bit and 64bit kernel. Because i want to make the write function independent and syscall has some CPU requirements. However when i change to syscall, the code still failed. Regards, Adam Paul Durrant wrote: On 4/10/07, Adam Zhang <[EMAIL PROTECTED]> w

Re: [osol-code] independent write function in assembly language

2007-04-10 Thread Paul Durrant
On 4/10/07, Adam Zhang <[EMAIL PROTECTED]> wrote: i just write an independent write function in assembly language to write a string to stderr. But the code doesn't work on Solaris. Below is the code: void write_stderr ( char * buf, int n ) { int block[2]; block[0] = (int) buf; block[1

[osol-code] independent write function in assembly language

2007-04-10 Thread Adam Zhang
Hi all, i just write an independent write function in assembly language to write a string to stderr. But the code doesn't work on Solaris. Below is the code: void write_stderr ( char * buf, int n ) { int block[2]; block[0] = (int) buf; block[1] = n; __asm__ volatile ( "pushl %%eb