#define write(fd, buf, count)	do_syscall(4, fd, buf, count)

int do_syscall(int number, ...)
{
  register int result;
  asm("push %ebx; push %esi; push %edi");
  asm(
    "mov 28(%%ebp),%%edi;"
    "mov 24(%%ebp),%%esi;"
    "mov 20(%%ebp),%%edx;"
    "mov 16(%%ebp),%%ecx;"
    "mov 12(%%ebp),%%ebx;"
    "mov  8(%%ebp),%%eax;"
    "int $0x80"
    : "=a" (result)
  );
  asm("pop %edi; pop %esi; pop %ebx");
  return result;
}
