Yuri wrote:
I guess I'd ask why you want to use syscall at all to just open a file? I thought you wanted to access some hardware and had no other way to do that.

Derek,

Opening a file is just an example. I want to be able to make any system call
this way since my program for whatever reasons has to be compiled with such gcc
options that prevent being linked to system calls in the traditional way. No
hardware issues for me.

Btw I submitted the wrong assembly code with my previous message.
The right one (still not working) is below.

Lack of documentation causes me to ask this kind of question here.

Yuri

---- code ---
#include <fcntl.h>

extern int mysyscall (
          int syscall_no,
          int a1, int a2, int a3,
          int a4, int a5, int a6);
asm(
".text\n"
"mysyscall:\n"
"       movl    %esp,%ebx\n"
"       push    28(%ebx)\n"
"       push    24(%ebx)\n"
"       push    20(%ebx)\n"
"       push    16(%ebx)\n"
"       push    12(%ebx)\n"
"       push    8(%ebx)\n"
"       push    4(%ebx)\n"
"       int     $0x80\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       pop     %ecx\n"
"       ret\n"
".previous\n"
);

main() {
  char *fname = "myxxxfile";
  //int fd = open(fname, O_WRONLY|O_CREAT);
  int fd = mysyscall(5, (int)fname,O_WRONLY|O_CREAT,0,0,0,0); // open
  printf("fd=%i\n",fd);
}
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

I think the problem may relate to how FreeBSD handles the stack. Try pushing an extra word, anything will do, before making the int 80. Let us know if that makes it work and I'll point to a link that explains it.
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to