...
Run Format

Text file src/runtime/internal/atomic/asm_amd64p32.s

Documentation: runtime/internal/atomic

     1	// Copyright 2015 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	#include "textflag.h"
     6	
     7	// bool Cas(int32 *val, int32 old, int32 new)
     8	// Atomically:
     9	//	if(*val == old){
    10	//		*val = new;
    11	//		return 1;
    12	//	} else
    13	//		return 0;
    14	TEXT runtime∕internal∕atomic·Cas(SB), NOSPLIT, $0-17
    15		MOVL	ptr+0(FP), BX
    16		MOVL	old+4(FP), AX
    17		MOVL	new+8(FP), CX
    18		LOCK
    19		CMPXCHGL	CX, 0(BX)
    20		SETEQ	ret+16(FP)
    21		RET
    22	
    23	TEXT runtime∕internal∕atomic·Casuintptr(SB), NOSPLIT, $0-17
    24		JMP	runtime∕internal∕atomic·Cas(SB)
    25	
    26	TEXT runtime∕internal∕atomic·Loaduintptr(SB), NOSPLIT, $0-12
    27		JMP	runtime∕internal∕atomic·Load(SB)
    28	
    29	TEXT runtime∕internal∕atomic·Loaduint(SB), NOSPLIT, $0-12
    30		JMP	runtime∕internal∕atomic·Load(SB)
    31	
    32	TEXT runtime∕internal∕atomic·Storeuintptr(SB), NOSPLIT, $0-8
    33		JMP	runtime∕internal∕atomic·Store(SB)
    34	
    35	TEXT runtime∕internal∕atomic·Loadint64(SB), NOSPLIT, $0-16
    36		JMP	runtime∕internal∕atomic·Load64(SB)
    37	
    38	TEXT runtime∕internal∕atomic·Xaddint64(SB), NOSPLIT, $0-24
    39		JMP	runtime∕internal∕atomic·Xadd64(SB)
    40	
    41	// bool	runtime∕internal∕atomic·cas64(uint64 *val, uint64 old, uint64 new)
    42	// Atomically:
    43	//	if(*val == *old){
    44	//		*val = new;
    45	//		return 1;
    46	//	} else {
    47	//		return 0;
    48	//	}
    49	TEXT runtime∕internal∕atomic·Cas64(SB), NOSPLIT, $0-25
    50		MOVL	ptr+0(FP), BX
    51		MOVQ	old+8(FP), AX
    52		MOVQ	new+16(FP), CX
    53		LOCK
    54		CMPXCHGQ	CX, 0(BX)
    55		SETEQ	ret+24(FP)
    56		RET
    57	
    58	// bool Casp1(void **val, void *old, void *new)
    59	// Atomically:
    60	//	if(*val == old){
    61	//		*val = new;
    62	//		return 1;
    63	//	} else
    64	//		return 0;
    65	TEXT runtime∕internal∕atomic·Casp1(SB), NOSPLIT, $0-17
    66		MOVL	ptr+0(FP), BX
    67		MOVL	old+4(FP), AX
    68		MOVL	new+8(FP), CX
    69		LOCK
    70		CMPXCHGL	CX, 0(BX)
    71		SETEQ	ret+16(FP)
    72		RET
    73	
    74	// uint32 Xadd(uint32 volatile *val, int32 delta)
    75	// Atomically:
    76	//	*val += delta;
    77	//	return *val;
    78	TEXT runtime∕internal∕atomic·Xadd(SB), NOSPLIT, $0-12
    79		MOVL	ptr+0(FP), BX
    80		MOVL	delta+4(FP), AX
    81		MOVL	AX, CX
    82		LOCK
    83		XADDL	AX, 0(BX)
    84		ADDL	CX, AX
    85		MOVL	AX, ret+8(FP)
    86		RET
    87	
    88	TEXT runtime∕internal∕atomic·Xadd64(SB), NOSPLIT, $0-24
    89		MOVL	ptr+0(FP), BX
    90		MOVQ	delta+8(FP), AX
    91		MOVQ	AX, CX
    92		LOCK
    93		XADDQ	AX, 0(BX)
    94		ADDQ	CX, AX
    95		MOVQ	AX, ret+16(FP)
    96		RET
    97	
    98	TEXT runtime∕internal∕atomic·Xadduintptr(SB), NOSPLIT, $0-12
    99		JMP	runtime∕internal∕atomic·Xadd(SB)
   100	
   101	TEXT runtime∕internal∕atomic·Xchg(SB), NOSPLIT, $0-12
   102		MOVL	ptr+0(FP), BX
   103		MOVL	new+4(FP), AX
   104		XCHGL	AX, 0(BX)
   105		MOVL	AX, ret+8(FP)
   106		RET
   107	
   108	TEXT runtime∕internal∕atomic·Xchg64(SB), NOSPLIT, $0-24
   109		MOVL	ptr+0(FP), BX
   110		MOVQ	new+8(FP), AX
   111		XCHGQ	AX, 0(BX)
   112		MOVQ	AX, ret+16(FP)
   113		RET
   114	
   115	TEXT runtime∕internal∕atomic·Xchguintptr(SB), NOSPLIT, $0-12
   116		JMP	runtime∕internal∕atomic·Xchg(SB)
   117	
   118	TEXT runtime∕internal∕atomic·StorepNoWB(SB), NOSPLIT, $0-8
   119		MOVL	ptr+0(FP), BX
   120		MOVL	val+4(FP), AX
   121		XCHGL	AX, 0(BX)
   122		RET
   123	
   124	TEXT runtime∕internal∕atomic·Store(SB), NOSPLIT, $0-8
   125		MOVL	ptr+0(FP), BX
   126		MOVL	val+4(FP), AX
   127		XCHGL	AX, 0(BX)
   128		RET
   129	
   130	TEXT runtime∕internal∕atomic·Store64(SB), NOSPLIT, $0-16
   131		MOVL	ptr+0(FP), BX
   132		MOVQ	val+8(FP), AX
   133		XCHGQ	AX, 0(BX)
   134		RET
   135	
   136	// void	runtime∕internal∕atomic·Or8(byte volatile*, byte);
   137	TEXT runtime∕internal∕atomic·Or8(SB), NOSPLIT, $0-5
   138		MOVL	ptr+0(FP), BX
   139		MOVB	val+4(FP), AX
   140		LOCK
   141		ORB	AX, 0(BX)
   142		RET
   143	
   144	// void	runtime∕internal∕atomic·And8(byte volatile*, byte);
   145	TEXT runtime∕internal∕atomic·And8(SB), NOSPLIT, $0-5
   146		MOVL	ptr+0(FP), BX
   147		MOVB	val+4(FP), AX
   148		LOCK
   149		ANDB	AX, 0(BX)
   150		RET

View as plain text