asm_nacl_amd64p32.s 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. #include "../../cmd/ld/textflag.h" // TODO: how to refer to this?
  5. #include "../runtime/syscall_nacl.h" // TODO: how to refer to this?
  6. //
  7. // System call support for amd64, Native Client
  8. //
  9. #define NACL_SYSCALL(code) \
  10. MOVL $(0x10000 + ((code)<<5)), AX; CALL AX
  11. #define NACL_SYSJMP(code) \
  12. MOVL $(0x10000 + ((code)<<5)), AX; JMP AX
  13. TEXT unix·Syscall(SB),NOSPLIT,$0-28
  14. CALL runtime·entersyscall(SB)
  15. MOVL trap+0(FP), AX
  16. MOVL a1+4(FP), DI
  17. MOVL a2+8(FP), SI
  18. MOVL a3+12(FP), DX
  19. // more args would use CX, R8, R9
  20. SHLL $5, AX
  21. ADDL $0x10000, AX
  22. CALL AX
  23. CMPL AX, $0
  24. JGE ok
  25. MOVL $-1, r1+16(FP)
  26. MOVL $-1, r2+20(FP)
  27. NEGL AX
  28. MOVL AX, err+24(FP)
  29. CALL runtime·exitsyscall(SB)
  30. RET
  31. ok:
  32. MOVL AX, r1+16(FP)
  33. MOVL DX, r2+20(FP)
  34. MOVL $0, err+24(FP)
  35. CALL runtime·exitsyscall(SB)
  36. RET