_syscall.s 603 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. ! $Source$
  3. ! $State$
  4. ! $Revision$
  5. #include "syscalls.h"
  6. ! Declare segments (the order is important).
  7. .sect .text
  8. .sect .rom
  9. .sect .data
  10. .sect .bss
  11. .sect .text
  12. EINVAL = 22
  13. ! Perform a Linux system call.
  14. .define __syscall
  15. __syscall:
  16. mov eax, 4(esp)
  17. mov ebx, 8(esp)
  18. mov ecx, 12(esp)
  19. mov edx, 16(esp)
  20. int 0x80
  21. or eax, eax
  22. jl 1f
  23. ret
  24. 1:
  25. neg eax
  26. ! It just so happens that errnos 1-34 are the same in Linux as in the ACK.
  27. cmp eax, 1
  28. jb 2f
  29. cmp eax, 34
  30. ja 2f
  31. mov (_errno), eax
  32. 3:
  33. mov eax, -1
  34. ret
  35. 2:
  36. ! All other errnos become EINVAL for now. FIXME dtrg.
  37. mov (_errno), EINVAL
  38. jmp 3b