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 block[2];
   block[0] = (int) buf;
   block[1] = n;
   __asm__ volatile (
      "pushl %%ebx\n"
      "movl  %0, %%ebx\n"
      "pushl %%ebx\n"
      "movl  0(%%ebx), %%ecx\n"
      "movl  4(%%ebx), %%edx\n"
      "movl  $4, %%eax\n"
      "movl  $2, %%ebx\n"
      "int  $0x91\n"

I imagine this is your problem. Is your kernel 32 or 64-bit? IIRC
system calls are handled differently in each case, and I don't think
either use int 0x91 anyway. I also have to ask... why can't you use
syscall()?

Not only that - but why do you even require to do this ?

int 0x91 is ok on recent OpenSolaris builds, for 32bit x86 apps. 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 ?


FrankH.


      "popl  %%ebx\n"
      "movl  %%eax, 0(%%ebx)\n"
      "popl  %%ebx\n"
      : /*wr*/
      : /*rd*/    "g" (block)
      : /*trash*/ "eax", "edi", "ecx", "edx", "memory", "cc"
   );
}

Does anyone know where i am wrong?
Thank you!

Regards,
adam

_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code



--
Paul Durrant
http://www.linkedin.com/in/pdurrant
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to