Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PRESERVE8
- THUMB
- GET config.s
- GET stm32f10x.s
- AREA RESET, CODE, READONLY
- DCD STACK_TOP
- DCD Reset_Handler
- ENTRY
- Reset_Handler PROC
- EXPORT Reset_Handler
- main
- MOV32 R0, 0x20000200 ; R0 - array start (arr)
- MOV R1, #64 ; R1 - array size (size)
- MOV R2, #0 ; R2 - array position (pos)
- loop
- CMP R2, R1 ; while (pos != aray_size)
- BLNE swap
- B loop
- ENDP
- swap PROC
- MOV R3, R0 ; R3 == arr
- MOV R4, R2 ; R4 == pos
- ADD R3, R4 ; R3 == arr + pos
- LDRB R5, [R3] ; load 8 bits into R5
- LDRB R6, [R3] ; load 8 bits into R6
- AND R5, #0xF0 ; R5 AND 11110000
- AND R6, #0x0F ; R6 AND 00001111
- LSRS R5, R5, #4 ; shift R5 to right 4 times
- LSLS R6, R6, #4 ; shift R6 to left 4 times
- ORR R6, R5 ; R6 OR R5
- MOV R5, R6 ; copy R6 to R5
- AND R5, #0xCC ; R5 AND 11001100
- AND R6, #0x33 ; R6 AND 00110011
- LSRS R5, R5, #2 ; shift R5 to right 2 times
- LSLS R6, R6, #2 ; shift R6 to left 2 times
- ORR R6, R5 ; R6 OR R5
- MOV R5, R6 ; copy R6 to R5
- AND R5, #0xAA ; R5 AND 10101010
- AND R6, #0x55 ; R6 AND 01010101
- LSRS R5, R5, #1 ; shift R5 to right 1 time
- LSLS R6, R6, #1 ; shift R6 to left 1 time
- ORR R6, R5 ; R6 OR R5
- STRB R6, [R3] ; copy result back to R3
- ADD R2, #1 ; pos++
- BX LR
- ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement