URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Go to most recent revision |
Show entire file |
Details |
Blame |
View Log
Rev 39 |
Rev 56 |
Line 8... |
Line 8... |
! r6: byte count
|
! r6: byte count
|
!
|
!
|
! Exit: r0-r3: trashed
|
! Exit: r0-r3: trashed
|
!
|
!
|
|
|
|
! This assumes that the first four bytes of the address space (0..3) are
|
|
! reserved - usually by the linker script. Otherwise, we would had to check
|
|
! for the case of objects of the size 12..15 at address 0..3 .
|
|
|
#include "asm.h"
|
#include "asm.h"
|
|
|
ENTRY(memset)
|
ENTRY(memset)
|
mov r4,r3 ! Save return value
|
|
|
|
mov r6,r0 ! Check explicitly for zero
|
|
cmp/eq #0,r0
|
|
bt L_exit
|
|
|
|
mov #12,r0 ! Check for small number of bytes
|
mov #12,r0 ! Check for small number of bytes
|
cmp/gt r6,r0
|
cmp/gt r6,r0
|
bt L_store_byte_loop
|
mov r4,r0
|
|
SL(bt, L_store_byte_loop_check0, add r4,r6)
|
|
|
neg r4,r0 ! Align destination
|
tst #3,r0 ! Align destination
|
add #4,r0
|
SL(bt, L_dup_bytes, extu.b r5,r5)
|
and #3,r0
|
|
tst r0,r0
|
|
bt L_dup_bytes
|
|
.balignw 4,0x0009
|
.balignw 4,0x0009
|
L_align_loop:
|
L_align_loop:
|
mov.b r5,@r4
|
mov.b r5,@r0
|
add #-1,r6
|
add #1,r0
|
add #1,r4
|
tst #3,r0
|
dt r0
|
|
bf L_align_loop
|
bf L_align_loop
|
|
|
L_dup_bytes:
|
L_dup_bytes:
|
extu.b r5,r5 ! Duplicate bytes across longword
|
swap.b r5,r2 ! Duplicate bytes across longword
|
swap.b r5,r0
|
or r2,r5
|
or r0,r5
|
swap.w r5,r2
|
swap.w r5,r0
|
or r2,r5
|
or r0,r5
|
|
|
add #-16,r6
|
mov r6,r2 ! Calculate number of double longwords
|
|
shlr2 r2
|
|
shlr r2
|
|
|
|
.balignw 4,0x0009
|
.balignw 4,0x0009
|
L_store_long_loop:
|
L_store_long_loop:
|
mov.l r5,@r4 ! Store double longs to memory
|
mov.l r5,@r0 ! Store double longs to memory
|
dt r2
|
cmp/hs r6,r0
|
mov.l r5,@(4,r4)
|
mov.l r5,@(4,r0)
|
add #8,r4
|
SL(bf, L_store_long_loop, add #8,r0)
|
bf L_store_long_loop
|
|
|
add #16,r6
|
mov #7,r0
|
|
and r0,r6
|
L_store_byte_loop_check0:
|
tst r6,r6
|
cmp/eq r6,r0
|
bt L_exit
|
bt L_exit
|
.balignw 4,0x0009
|
.balignw 4,0x0009
|
L_store_byte_loop:
|
L_store_byte_loop:
|
mov.b r5,@r4 ! Store bytes to memory
|
mov.b r5,@r0 ! Store bytes to memory
|
add #1,r4
|
add #1,r0
|
dt r6
|
cmp/eq r6,r0
|
bf L_store_byte_loop
|
bf L_store_byte_loop
|
|
|
L_exit:
|
L_exit:
|
rts
|
rts
|
mov r3,r0
|
mov r4,r0
|
|
|
© copyright 1999-2025
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.