arch/sh/lib/memmove.S

Source file repositories/reference/linux-study-clean/arch/sh/lib/memmove.S

File Facts

System
Linux kernel
Corpus path
arch/sh/lib/memmove.S
Extension
.S
Size
4048 bytes
Lines
256
Domain
Architecture Layer
Bucket
arch/sh
Inferred role
Architecture Layer: arch/sh
Status
atlas-only

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

#include <linux/linkage.h>
ENTRY(memmove)
	! if dest > src, call memcpy (it copies in decreasing order)
	cmp/hi	r5,r4
	bf	1f
	mov.l	2f,r0
	jmp	@r0
	 nop
	.balign 4
2:	.long	memcpy
1:
	sub	r5,r4		! From here, r4 has the distance to r0
	tst	r6,r6
	bt/s	9f		! if n=0, do nothing
	 mov	r5,r0
	add	r6,r5
	mov	#12,r1
	cmp/gt	r6,r1
	bt/s	8f		! if it's too small, copy a byte at once
	 add	#-1,r4
	add	#1,r4
	!
	!                [ ...  ] DST             [ ...  ] SRC
	!	         [ ...  ]                 [ ...  ]
	!	           :                        :
	!      r0+r4-->  [ ...  ]       r0    --> [ ...  ]
	!	           :                        :
	!	         [ ...  ]                 [ ...  ]
	!			        r5    -->
	!
	mov	r4,r1
	mov	#3,r2
	and	r2,r1
	shll2	r1
	mov	r0,r3		! Save the value on R0 to R3
	mova	jmptable,r0
	add	r1,r0
	mov.l	@r0,r1
	jmp	@r1
	 mov	r3,r0		! and back to R0
	.balign	4
jmptable:
	.long	case0
	.long	case1
	.long	case2
	.long	case3

	! copy a byte at once
8:	mov.b	@r0+,r1
	cmp/hs	r5,r0
	bf/s	8b			! while (r0<r5)
	 mov.b	r1,@(r0,r4)
	add	#1,r4
9:
	add	r4,r0
	rts
	 sub	r6,r0

case_none:
	bra	8b
	 add	#-1,r4

case0:
	!
	!	GHIJ KLMN OPQR -->  GHIJ KLMN OPQR
	!
	! First, align to long word boundary
	mov	r0,r3
	and	r2,r3
	tst	r3,r3

Annotation

Implementation Notes