1// Copyright 2018 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
5//go:build !faketime
6
7#include "go_asm.h"
8#include "textflag.h"
9#include "time_windows.h"
10
11TEXT time·now(SB),NOSPLIT,$0-24
12	MOVD	$_INTERRUPT_TIME, R3
13	MOVD	time_lo(R3), R0
14	MOVD	$100, R1
15	MUL	R1, R0
16	MOVD	R0, mono+16(FP)
17
18	MOVD	$_SYSTEM_TIME, R3
19	MOVD	time_lo(R3), R0
20	// convert to Unix epoch (but still 100ns units)
21	#define delta 116444736000000000
22	SUB	$delta, R0
23	// Convert to nSec
24	MOVD	$100, R1
25	MUL	R1, R0
26
27	// Code stolen from compiler output for:
28	//
29	//	var x uint64
30	//	func f() (sec uint64, nsec uint32) { return x / 1000000000, uint32(x % 1000000000) }
31	//
32	LSR	$1, R0, R1
33	MOVD	$-8543223759426509416, R2
34	UMULH	R1, R2, R1
35	LSR	$28, R1, R1
36	MOVD	R1, sec+0(FP)
37	MOVD	$1000000000, R2
38	MSUB	R1, R0, R2, R0
39	MOVW	R0, nsec+8(FP)
40	RET
41
42