#include "zasm_GOOS_GOARCH.h"
#include "../../cmd/ld/textflag.h"
TEXT runtime·exit(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL $(0x2000000+1), AX
SYSCALL
MOVL $0xf1, 0xf1
RET
TEXT runtime·exit1(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL $(0x2000000+361), AX
SYSCALL
MOVL $0xf1, 0xf1
RET
TEXT runtime·open(SB),NOSPLIT,$0
MOVQ 8(SP), DI
MOVL 16(SP), SI
MOVL 20(SP), DX
MOVL $(0x2000000+5), AX
SYSCALL
RET
TEXT runtime·close(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL $(0x2000000+6), AX
SYSCALL
RET
TEXT runtime·read(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVL 24(SP), DX
MOVL $(0x2000000+3), AX
SYSCALL
RET
TEXT runtime·write(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVL 24(SP), DX
MOVL $(0x2000000+4), AX
SYSCALL
RET
TEXT runtime·raise(SB),NOSPLIT,$24
MOVL $(0x2000000+20), AX
SYSCALL
MOVQ AX, DI
MOVL sig+0(FP), SI
MOVL $1, DX
MOVL $(0x2000000+37), AX
SYSCALL
RET
TEXT runtime·setitimer(SB), NOSPLIT, $0
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVQ 24(SP), DX
MOVL $(0x2000000+83), AX
SYSCALL
RET
TEXT runtime·madvise(SB), NOSPLIT, $0
MOVQ 8(SP), DI
MOVQ 16(SP), SI
MOVL 24(SP), DX
MOVL $(0x2000000+75), AX
SYSCALL
RET
#define nt_tsc_base 0x50
#define nt_scale 0x58
#define nt_shift 0x5c
#define nt_ns_base 0x60
#define nt_generation 0x68
#define gtod_generation 0x6c
#define gtod_ns_base 0x70
#define gtod_sec_base 0x78
TEXT runtime·nanotime(SB), NOSPLIT, $32
MOVQ $0x7fffffe00000, BP
timeloop:
MOVL gtod_generation(BP), R8
TESTL R8, R8
JZ systime
MOVL nt_generation(BP), R9
TESTL R9, R9
JZ timeloop
RDTSC
MOVQ nt_tsc_base(BP), R10
MOVL nt_scale(BP), R11
MOVQ nt_ns_base(BP), R12
CMPL nt_generation(BP), R9
JNE timeloop
MOVQ gtod_ns_base(BP), R13
MOVQ gtod_sec_base(BP), R14
CMPL gtod_generation(BP), R8
JNE timeloop
SHLQ $32, DX
ADDQ DX, AX
SUBQ R10, AX
MULQ R11
SHRQ $32, AX:DX
ADDQ R12, AX
SUBQ R13, AX
IMULQ $1000000000, R14
ADDQ R14, AX
RET
systime:
MOVQ SP, DI
MOVQ $0, SI
MOVL $(0x2000000+116), AX
SYSCALL
IMULQ $1000000000, AX
IMULQ $1000, DX
ADDQ DX, AX
RET
TEXT time·now(SB),NOSPLIT,$0
CALL runtime·nanotime(SB)
MOVQ AX, CX
MOVQ $1360296554856532783, AX
MULQ CX
ADDQ CX, DX
RCRQ $1, DX
SHRQ $29, DX
MOVQ DX, sec+0(FP)
IMULQ $1000000000, DX
SUBQ DX, CX
MOVL CX, nsec+8(FP)
RET
TEXT runtime·sigprocmask(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVQ 24(SP), DX
MOVL $(0x2000000+329), AX
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1
RET
TEXT runtime·sigaction(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVQ 24(SP), DX
MOVQ 24(SP), CX
MOVQ 24(SP), R10
MOVL $(0x2000000+46), AX
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1
RET
TEXT runtime·sigtramp(SB),NOSPLIT,$64
get_tls(BX)
MOVQ R8, 32(SP)
MOVQ SI, 40(SP)
MOVQ m(BX), BP
CMPQ BP, $0
JNE 5(PC)
MOVL DX, 0(SP)
MOVQ $runtime·badsignal(SB), AX
CALL AX
JMP sigtramp_ret
MOVQ g(BX), R10
MOVQ R10, 48(SP)
MOVQ m_gsignal(BP), BP
MOVQ BP, g(BX)
MOVL DX, 0(SP)
MOVQ CX, 8(SP)
MOVQ R8, 16(SP)
MOVQ R10, 24(SP)
CALL DI
get_tls(BX)
MOVQ 48(SP), R10
MOVQ R10, g(BX)
sigtramp_ret:
MOVL $(0x2000000+184), AX
MOVQ 32(SP), DI
MOVQ 40(SP), SI
SYSCALL
INT $3
TEXT runtime·mmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI
MOVQ 16(SP), SI
MOVL 24(SP), DX
MOVL 28(SP), R10
MOVL 32(SP), R8
MOVL 36(SP), R9
MOVL $(0x2000000+197), AX
SYSCALL
RET
TEXT runtime·munmap(SB),NOSPLIT,$0
MOVQ 8(SP), DI
MOVQ 16(SP), SI
MOVL $(0x2000000+73), AX
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1
RET
TEXT runtime·sigaltstack(SB),NOSPLIT,$0
MOVQ new+8(SP), DI
MOVQ old+16(SP), SI
MOVQ $(0x2000000+53), AX
SYSCALL
JCC 2(PC)
MOVL $0xf1, 0xf1
RET
TEXT runtime·usleep(SB),NOSPLIT,$16
MOVL $0, DX
MOVL usec+0(FP), AX
MOVL $1000000, CX
DIVL CX
MOVQ AX, 0(SP)
MOVL DX, 8(SP)
MOVL $0, DI
MOVL $0, SI
MOVL $0, DX
MOVL $0, R10
MOVQ SP, R8
MOVL $(0x2000000+93), AX
SYSCALL
RET
TEXT runtime·bsdthread_create(SB),NOSPLIT,$0
MOVQ fn+32(SP), DI
MOVQ mm+16(SP), SI
MOVQ stk+8(SP), DX
MOVQ gg+24(SP), R10
MOVQ $0x01000000, R8
MOVQ $0, R9
MOVQ $(0x2000000+360), AX
SYSCALL
JCC 3(PC)
NEGQ AX
RET
MOVL $0, AX
RET
TEXT runtime·bsdthread_start(SB),NOSPLIT,$0
MOVQ R8, SP
PUSHQ DX
PUSHQ CX
PUSHQ SI
LEAQ m_tls(CX), DI
CALL runtime·settls(SB)
POPQ SI
POPQ CX
POPQ DX
get_tls(BX)
MOVQ CX, m(BX)
MOVQ SI, m_procid(CX)
MOVQ m_g0(CX), AX
MOVQ AX, g(BX)
CALL runtime·stackcheck(SB)
CALL DX
CALL runtime·exit1(SB)
RET
TEXT runtime·bsdthread_register(SB),NOSPLIT,$0
MOVQ $runtime·bsdthread_start(SB), DI
MOVQ $0, SI
MOVQ $0, DX
MOVQ $0, R10
MOVQ $0, R8
MOVQ $0, R9
MOVQ $(0x2000000+366), AX
SYSCALL
JCC 3(PC)
NEGQ AX
RET
MOVL $0, AX
RET
TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0
MOVQ 8(SP), DI
MOVL 16(SP), SI
MOVL 20(SP), DX
MOVL 24(SP), R10
MOVL 28(SP), R8
MOVL 32(SP), R9
MOVL 36(SP), R11
PUSHQ R11
MOVL $(0x1000000+31), AX
SYSCALL
POPQ R11
RET
TEXT runtime·mach_task_self(SB),NOSPLIT,$0
MOVL $(0x1000000+28), AX
SYSCALL
RET
TEXT runtime·mach_thread_self(SB),NOSPLIT,$0
MOVL $(0x1000000+27), AX
SYSCALL
RET
TEXT runtime·mach_reply_port(SB),NOSPLIT,$0
MOVL $(0x1000000+26), AX
SYSCALL
RET
TEXT runtime·mach_semaphore_wait(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL $(0x1000000+36), AX
SYSCALL
RET
TEXT runtime·mach_semaphore_timedwait(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL 12(SP), SI
MOVL 16(SP), DX
MOVL $(0x1000000+38), AX
SYSCALL
RET
TEXT runtime·mach_semaphore_signal(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL $(0x1000000+33), AX
SYSCALL
RET
TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVL $(0x1000000+34), AX
SYSCALL
RET
TEXT runtime·settls(SB),NOSPLIT,$32
SUBQ $0x8a0, DI
MOVL $(0x3000000+3), AX
SYSCALL
RET
TEXT runtime·sysctl(SB),NOSPLIT,$0
MOVQ 8(SP), DI
MOVL 16(SP), SI
MOVQ 24(SP), DX
MOVQ 32(SP), R10
MOVQ 40(SP), R8
MOVQ 48(SP), R9
MOVL $(0x2000000+202), AX
SYSCALL
JCC 3(PC)
NEGQ AX
RET
MOVL $0, AX
RET
TEXT runtime·kqueue(SB),NOSPLIT,$0
MOVQ $0, DI
MOVQ $0, SI
MOVQ $0, DX
MOVL $(0x2000000+362), AX
SYSCALL
JCC 2(PC)
NEGQ AX
RET
TEXT runtime·kevent(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVQ 16(SP), SI
MOVL 24(SP), DX
MOVQ 32(SP), R10
MOVL 40(SP), R8
MOVQ 48(SP), R9
MOVL $(0x2000000+363), AX
SYSCALL
JCC 2(PC)
NEGQ AX
RET
TEXT runtime·closeonexec(SB),NOSPLIT,$0
MOVL 8(SP), DI
MOVQ $2, SI
MOVQ $1, DX
MOVL $(0x2000000+92), AX
SYSCALL
RET