Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AREA Shift64, CODE, READONLY
- IMPORT main
- EXPORT start
- start
- LDR R0, =0x13131313 ; least significant (LS) word
- LDR R1, =0x13131313 ; most significant (MS) word
- LDR R2, =-2 ; number of places to shift (n)
- LDR R3, =0 ; number of bits to shift to get bits which move between registers (n most/least significant bits)
- LDR R4, =0 ; tempValue - the bits which move between registers
- LDR R5, =32 ;
- CMP R2, #0 ; if (n<0)
- BLT shiftLeft ; go to shiftLeft
- shiftRight
- SUB R3, R5, R2 ; 32-n
- MOV R4, R1, LSL R3 ; tempValue
- MOV R0, R0, LSR R2 ; move LS word right by n bits
- ORR R0, R0, R4 ; add tempValue to beginning of LS word
- MOV R1, R1, LSR R2 ; move MS word right by n bits
- B stop
- shiftLeft
- SUB R2, R3, R2 ; |n| ; 0-(-n) = n
- SUB R3, R5, R2 ; 32-n
- MOV R4, R0, LSR R3 ; tempValue
- MOV R1, R1, LSL R2 ; move MS word left by n bits
- ORR R1, R1, R4 ; add tempValue to end of MS word
- MOV R0, R0, LSL R2 ; move LS word left by n bits
- stop B stop
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement