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 Linux, on 32bit x86, Solaris passes
parameters via stack by "push" instead of using registers.
That means, you should besides using %eax as syscall number, you should
push necessary parameters into stack before issuing "int 0x91".
You could use mdb debug your program by setting break point before int
0x91, check whether you provide right parameters in stack and %eax.
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" "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
--
Cheers,
----------------------------------------------------------------------
Oliver Yang | [EMAIL PROTECTED] | x82229 | Work from home
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code