movexamps.s 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. @
  2. @ Examples of the MOV instruction.
  3. @
  4. .global _start @Provide program starting address
  5. @ Load R2 with 0x4F5D6E3A first using MOV and MOVT
  6. _start:
  7. MOV R2, #0x6E3A
  8. MOVT R2, #0x4F5D
  9. @ Just move R2 into R1
  10. MOV R1, R2
  11. @ Now let's see all the shift versions of MOV
  12. MOV R1, R2, LSL #1 @ Logical shift left
  13. MOV R1, R2, LSR #1 @ Logical shift right
  14. MOV R1, R2, ASR #1 @ Arithmetic shift right
  15. MOV R1, R2, ROR #1 @ Rotate right
  16. MOV R1, R2, RRX @ Rotate extended right
  17. @ Repeat the above shifts using
  18. @ the Assembler mnemonics
  19. LSL R1, R2, #1 @ Logical shift left
  20. LSR R1, R2, #1 @ Logical shift right
  21. ASR R1, R2, #1 @ Arithmetic shift right
  22. ROR R1, R2, #1 @ Rotate right
  23. RRX R1, R2 @ Rotate extended right
  24. @ Example that works with 8 bit immediate and shift
  25. MOV R1, #0xAB000000 @ Too big for #imm16
  26. @ Example that can't be represented and
  27. @ results in an error
  28. @ Uncomment the instruction if you want to
  29. @ see the error
  30. @ MOV R1, #X0ABCDEF11 @ Too big for #imm16
  31. @ Example of MVN
  32. MVN R1, #45
  33. @ Example of a MOV that the Assembler will
  34. @ change to MVN
  35. MOV R1, #0xFFFFFFFE @ (-2)
  36. @ Set the parameters to exit the program
  37. @ and then call Linux to do it.
  38. MOV R0, #0 @ Use 0 return code
  39. MOV R7, #1 @ Service command code 1
  40. SVC 0 @ Call Linux to terminate