2019-11-03 10:58:37 -07:00
|
|
|
// Copyright 2016 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "textflag.h"
|
|
|
|
|
2020-01-06 09:10:26 -07:00
|
|
|
// See memmove Go doc for important implementation constraints.
|
|
|
|
|
2019-11-03 10:58:37 -07:00
|
|
|
// void runtime·memmove(void*, void*, uintptr)
|
2021-11-06 08:38:51 -06:00
|
|
|
TEXT runtime·memmove<ABIInternal>(SB),NOSPLIT,$-0-24
|
2022-10-17 07:58:56 -06:00
|
|
|
// A0 = to
|
|
|
|
// A1 = from
|
|
|
|
// A2 = n
|
2021-11-06 08:38:51 -06:00
|
|
|
ADD A1, A2, T5
|
2019-11-03 10:58:37 -07:00
|
|
|
|
|
|
|
// If the destination is ahead of the source, start at the end of the
|
|
|
|
// buffer and go backward.
|
2021-11-06 08:38:51 -06:00
|
|
|
BLTU A1, A0, b
|
2019-11-03 10:58:37 -07:00
|
|
|
|
|
|
|
// If less than eight bytes, do one byte at a time.
|
2021-11-06 08:38:51 -06:00
|
|
|
SLTU $8, A2, T3
|
2019-11-03 10:58:37 -07:00
|
|
|
BNE T3, ZERO, f_outcheck
|
|
|
|
|
|
|
|
// Do one byte at a time until from is eight-aligned.
|
|
|
|
JMP f_aligncheck
|
|
|
|
f_align:
|
2021-11-06 08:38:51 -06:00
|
|
|
MOVB (A1), T3
|
|
|
|
MOVB T3, (A0)
|
|
|
|
ADD $1, A0
|
|
|
|
ADD $1, A1
|
2019-11-03 10:58:37 -07:00
|
|
|
f_aligncheck:
|
2021-11-06 08:38:51 -06:00
|
|
|
AND $7, A1, T3
|
2019-11-03 10:58:37 -07:00
|
|
|
BNE T3, ZERO, f_align
|
|
|
|
|
|
|
|
// Do eight bytes at a time as long as there is room.
|
|
|
|
ADD $-7, T5, T6
|
|
|
|
JMP f_wordscheck
|
|
|
|
f_words:
|
2021-11-06 08:38:51 -06:00
|
|
|
MOV (A1), T3
|
|
|
|
MOV T3, (A0)
|
|
|
|
ADD $8, A0
|
|
|
|
ADD $8, A1
|
2019-11-03 10:58:37 -07:00
|
|
|
f_wordscheck:
|
2021-11-06 08:38:51 -06:00
|
|
|
SLTU T6, A1, T3
|
2019-11-03 10:58:37 -07:00
|
|
|
BNE T3, ZERO, f_words
|
|
|
|
|
|
|
|
// Finish off the remaining partial word.
|
|
|
|
JMP f_outcheck
|
|
|
|
f_out:
|
2021-11-06 08:38:51 -06:00
|
|
|
MOVB (A1), T3
|
|
|
|
MOVB T3, (A0)
|
|
|
|
ADD $1, A0
|
|
|
|
ADD $1, A1
|
2019-11-03 10:58:37 -07:00
|
|
|
f_outcheck:
|
2021-11-06 08:38:51 -06:00
|
|
|
BNE A1, T5, f_out
|
2019-11-03 10:58:37 -07:00
|
|
|
|
|
|
|
RET
|
|
|
|
|
|
|
|
b:
|
2021-11-06 08:38:51 -06:00
|
|
|
ADD A0, A2, T4
|
2019-11-03 10:58:37 -07:00
|
|
|
// If less than eight bytes, do one byte at a time.
|
2021-11-06 08:38:51 -06:00
|
|
|
SLTU $8, A2, T3
|
2019-11-03 10:58:37 -07:00
|
|
|
BNE T3, ZERO, b_outcheck
|
|
|
|
|
|
|
|
// Do one byte at a time until from+n is eight-aligned.
|
|
|
|
JMP b_aligncheck
|
|
|
|
b_align:
|
|
|
|
ADD $-1, T4
|
|
|
|
ADD $-1, T5
|
|
|
|
MOVB (T5), T3
|
|
|
|
MOVB T3, (T4)
|
|
|
|
b_aligncheck:
|
|
|
|
AND $7, T5, T3
|
|
|
|
BNE T3, ZERO, b_align
|
|
|
|
|
|
|
|
// Do eight bytes at a time as long as there is room.
|
2021-11-06 08:38:51 -06:00
|
|
|
ADD $7, A1, T6
|
2019-11-03 10:58:37 -07:00
|
|
|
JMP b_wordscheck
|
|
|
|
b_words:
|
|
|
|
ADD $-8, T4
|
|
|
|
ADD $-8, T5
|
|
|
|
MOV (T5), T3
|
|
|
|
MOV T3, (T4)
|
|
|
|
b_wordscheck:
|
|
|
|
SLTU T5, T6, T3
|
|
|
|
BNE T3, ZERO, b_words
|
|
|
|
|
|
|
|
// Finish off the remaining partial word.
|
|
|
|
JMP b_outcheck
|
|
|
|
b_out:
|
|
|
|
ADD $-1, T4
|
|
|
|
ADD $-1, T5
|
|
|
|
MOVB (T5), T3
|
|
|
|
MOVB T3, (T4)
|
|
|
|
b_outcheck:
|
2021-11-06 08:38:51 -06:00
|
|
|
BNE T5, A1, b_out
|
2019-11-03 10:58:37 -07:00
|
|
|
|
|
|
|
RET
|