github.com/primecitizens/pcz/std@v0.2.1/core/mem/clear_plan9_386.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2014 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build pcz && 386 && plan9 9 10 #include "textflag.h" 11 12 // See memclrNoHeapPointers Go doc for important implementation constraints. 13 14 // func Clear(ptr unsafe.Pointer, n uintptr) 15 TEXT ·Clear(SB), NOSPLIT, $0-8 16 MOVL ptr+0(FP), DI 17 MOVL n+4(FP), BX 18 XORL AX, AX 19 20 tail: 21 TESTL BX, BX 22 JEQ _0 23 CMPL BX, $2 24 JBE _1or2 25 CMPL BX, $4 26 JB _3 27 JE _4 28 CMPL BX, $8 29 JBE _5through8 30 CMPL BX, $16 31 JBE _9through16 32 MOVL BX, CX 33 SHRL $2, CX 34 REP 35 STOSL 36 ANDL $3, BX 37 JNE tail 38 RET 39 40 _1or2: 41 MOVB AX, (DI) 42 MOVB AX, -1(DI)(BX*1) 43 RET 44 _0: 45 RET 46 _3: 47 MOVW AX, (DI) 48 MOVB AX, 2(DI) 49 RET 50 _4: 51 // We need a separate case for 4 to make sure we clear pointers atomically. 52 MOVL AX, (DI) 53 RET 54 _5through8: 55 MOVL AX, (DI) 56 MOVL AX, -4(DI)(BX*1) 57 RET 58 _9through16: 59 MOVL AX, (DI) 60 MOVL AX, 4(DI) 61 MOVL AX, -8(DI)(BX*1) 62 MOVL AX, -4(DI)(BX*1) 63 RET