Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 2.73 KB | None | 0 0
  1. ; ------------------------------------------------------------------
  2. ; --  _____       ______  _____                                    -
  3. ; -- |_   _|     |  ____|/ ____|                                   -
  4. ; --   | |  _ __ | |__  | (___    Institute of Embedded Systems    -
  5. ; --   | | | '_ \|  __|  \___ \   Zurich University of             -
  6. ; --  _| |_| | | | |____ ____) |  Applied Sciences                 -
  7. ; -- |_____|_| |_|______|_____/   8401 Winterthur, Switzerland     -
  8. ; ------------------------------------------------------------------
  9. ; --
  10. ; -- arithm.s
  11. ; --
  12. ; -- CT1 P05 Summe und Differenz
  13. ; --
  14. ; -- $Id: arithm.s 549 2014-09-01 13:00:11Z muln $
  15. ; ------------------------------------------------------------------
  16. ;Directives
  17.         PRESERVE8
  18.         THUMB
  19.  
  20. ; ------------------------------------------------------------------
  21. ; -- myCode
  22. ; ------------------------------------------------------------------
  23.         AREA MyCode, CODE, READONLY
  24.  
  25. main    PROC
  26.         EXPORT main
  27.  
  28. user_prog
  29.        
  30. ; ------------------------------------------------------------------
  31. ; -- Increment/Decrement with ADDS and SUBS
  32.         MOVS    R1, #0
  33.         ADDS    R1, R1, #1
  34.         ADDS    R1, R1, #1
  35.         SUBS    R1, R1, #1
  36.         SUBS    R1, R1, #1
  37.         SUBS    R1, R1, #1
  38.         SUBS    R1, R1, #1
  39.         SUBS    R1, R1, #1
  40.         ADDS    R1, R1, #1
  41.         ADDS    R1, R1, #1
  42.         ADDS    R1, R1, #1
  43.         ADDS    R1, R1, #1
  44.         ADDS    R1, R1, #1
  45.        
  46.        
  47. ; ------------------------------------------------------------------
  48. ; -- ADDS and SUBS (negative, positive, overflow)
  49.         LDR     R0, =0x6a000000
  50.         LDR     R1, =0x2efffffe
  51.         ADDS    R1, R1, R1
  52.         ADDS    R0, R0, R1
  53.         ADDS    R0, R0, R1
  54.        
  55.         LDR     R0, =0xa1000000
  56.         LDR     R1, =0x5efffffe
  57.         SUBS    R0, R0, R1
  58.         SUBS    R0, R0, R1
  59.  
  60. ; ------------------------------------------------------------------
  61. ; -- ADDS and RSBS vs. SUBS (compare R0 and R2)
  62.         LDR     R0, =0x4a000000
  63.         LDR     R1, =0x2efffffe
  64.         MOV     R2, R0
  65.  
  66.         SUBS    R0, R0, R1
  67.         RSBS    R1, R1, #0
  68.         ADDS    R2, R2, R1
  69.  
  70. ; ------------------------------------------------------------------
  71. ; -- MUL flags and cut-off if result needs more than 32 bits
  72.         LDR     R0, =0x0000e200
  73.         LDR     R1, =0x00002201
  74.        
  75.         MULS    R0, R1, R0
  76.         LDR     R1, =0x00000f20
  77.         MULS    R0, R1, R0
  78.         MULS    R0, R1, R0
  79.  
  80.         B       user_prog
  81.         ALIGN
  82. ; ------------------------------------------------------------------
  83. ; End of code
  84. ; ------------------------------------------------------------------
  85.         ENDP
  86.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement