自己写的几个ARM汇编内存操作函数
@=====================Subroutine====================
@ sysMemSet, Memory set in byte transfer (1 byte)
@ R0: Destination Address
@ R1: value
@ R2: Length in Bytes
@===================================================
.type sysMemSet, %function
.global sysMemSet
sysMemSet:
CMP R2, #0x00
BEQ .MemSetEnd
.MemSetLoop:
STRB R1, [R0], #+1
SUBS R2, R2, #1
BNE .MemSetLoop
.MemSetEnd:
MOV PC, LR
@=====================Subroutine====================
@ sysMemSetHW, Memory set in half word (2 bytes)
@ R0: Destination Address
@ R1: value
@ R2: Length in half words
@===================================================
.type sysMemSetHW, %function
.global sysMemSetHW
sysMemSetHW:
CMP R2, #0x00
BEQ .MemSetHWEnd
.MemSetHWLoop:
STRH R1, [R0], #+2
SUBS R2, R2, #1
BNE .MemSetHWLoop
.MemSetHWEnd:
MOV PC, LR
@=====================Subroutine====================
@ sysMemSetW, Memory set in word (4 bytes)
@ R0: Destination Address
@ R1: value
@ R2: Length in words
@===================================================
.type sysMemSetW, %function
.global sysMemSetW
sysMemSetW:
CMP R2, #0x00
BEQ .MemSetWEnd
.MemSetWLoop:
STR R1, [R0], #+4
SUBS R2, R2, #1
BNE .MemSetWLoop
.MemSetWEnd:
MOV PC, LR
@=====================Subroutine====================
@ sysMemCopy, Copy Memory data in byte transfer
@ R0: Destination Address
@ R1: Source Address
@ R2: Length in Bytes
@===================================================
.type sysMemCopy, %function
.global sysMemCopy
sysMemCopy:
CMP R2, #0x00
BEQ .MemCopyEnd
.MemCopyLoop:
LDRB R3, [R1], #+1
STRB R3, [R0], #+1
SUBS R2, R2, #1
BNE .MemCopyLoop
.MemCopyEnd:
MOV PC, LR
@=====================Subroutine====================
@ sysMemCopyHW, Copy Memory data in byte transfer
@ R0: Destination Address
@ R1: Source Address
@ R2: Length in half words
@===================================================
.type sysMemCopyHW, %function
.global sysMemCopyHW
sysMemCopyHW:
CMP R2, #0x00
BEQ .MemCopyHWEnd
.MemCopyHWLoop:
LDRH R3, [R1], #+2
STRH R3, [R0], #+2
SUBS R2, R2, #1
BNE .MemCopyHWLoop
.MemCopyHWEnd:
MOV PC, LR
@=====================Subroutine====================
@ sysMemCopyW, Copy Memory data in byte transfer
@ R0: Destination Address
@ R1: Source Address
@ R2: Length in words
@===================================================
.type sysMemCopyW, %function
.global sysMemCopyW
sysMemCopyW:
CMP R2, #0x00
BEQ .MemCopyWEnd
.MemCopyWLoop:
LDR R3, [R1], #+4
STR R3, [R0], #+4
SUBS R2, R2, #1
BNE .MemCopyWLoop
.MemCopyWEnd:
MOV PC, LR
@=====================Subroutine====================
@ sysMemCopyRev, Copy Memory data in byte transfer
@ R0: Destination Address
@ R1: Source Address
@ R2: Length in Bytes
@===================================================
.type sysMemCopyRev, %function
.global sysMemCopyRev
sysMemCopyRev:
CMP R2, #0x00
BEQ .RamCopyRevEnd
.RamCopyRevLoop:
LDRB R3, [R1], #-1
STRB R3, [R0], #-1
SUBS R2, R2, #1
BNE .RamCopyRevLoop
.RamCopyRevEnd:
MOV PC, LR
阅读(4393) | 评论(0) | 转发(0) |