Help us shape the future of Go! Take the 2026 Go Developer Survey

Text file src/runtime/time_windows_386.s

     1  // Copyright 2009 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 "funcdata.h"
    10  #include "time_windows.h"
    11  
    12  TEXT time·now(SB),NOSPLIT,$8-20
    13  	NO_LOCAL_POINTERS
    14  	CALL	runtime·nanotime1(SB)
    15  	MOVL	0(SP), AX
    16  	MOVL	4(SP), DX
    17  	MOVL	AX, mono+12(FP)
    18  	MOVL	DX, mono+16(FP)
    19  
    20  wall:
    21  	MOVL	(_SYSTEM_TIME+time_hi1), CX
    22  	MOVL	(_SYSTEM_TIME+time_lo), AX
    23  	MOVL	(_SYSTEM_TIME+time_hi2), DX
    24  	CMPL	CX, DX
    25  	JNE	wall
    26  
    27  	// w = DX:AX
    28  	// convert to Unix epoch (but still 100ns units)
    29  	#define delta 116444736000000000
    30  	SUBL	$(delta & 0xFFFFFFFF), AX
    31  	SBBL $(delta >> 32), DX
    32  
    33  	// nano/100 = DX:AX
    34  	// split into two decimal halves by div 1e9.
    35  	// (decimal point is two spots over from correct place,
    36  	// but we avoid overflow in the high word.)
    37  	MOVL	$1000000000, CX
    38  	DIVL	CX
    39  	MOVL	AX, DI
    40  	MOVL	DX, SI
    41  
    42  	// DI = nano/100/1e9 = nano/1e11 = sec/100, DX = SI = nano/100%1e9
    43  	// split DX into seconds and nanoseconds by div 1e7 magic multiply.
    44  	MOVL	DX, AX
    45  	MOVL	$1801439851, CX
    46  	MULL	CX
    47  	SHRL	$22, DX
    48  	MOVL	DX, BX
    49  	IMULL	$10000000, DX
    50  	MOVL	SI, CX
    51  	SUBL	DX, CX
    52  
    53  	// DI = sec/100 (still)
    54  	// BX = (nano/100%1e9)/1e7 = (nano/1e9)%100 = sec%100
    55  	// CX = (nano/100%1e9)%1e7 = (nano%1e9)/100 = nsec/100
    56  	// store nsec for return
    57  	IMULL	$100, CX
    58  	MOVL	CX, nsec+8(FP)
    59  
    60  	// DI = sec/100 (still)
    61  	// BX = sec%100
    62  	// construct DX:AX = 64-bit sec and store for return
    63  	MOVL	$0, DX
    64  	MOVL	$100, AX
    65  	MULL	DI
    66  	ADDL	BX, AX
    67  	ADCL	$0, DX
    68  	MOVL	AX, sec+0(FP)
    69  	MOVL	DX, sec+4(FP)
    70  	RET
    71  

View as plain text