Advertisement
Garey

Exercise1_9

Apr 9th, 2020
3,959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.49 KB | None | 0 0
  1. .global start
  2.  
  3. start:
  4.     MOV R0, #6              @ Number of elements
  5.  
  6.     LDR R1, =myNumber       @ Get address of myNumber
  7.     LDR R5, [R0]            @ Get Large Number
  8.     LDR R1, =array          @ Load array address
  9.  
  10.     MOV R3, #1              @ Store Product
  11.     MOV R4, #2              @ Current Element
  12.  
  13. check:
  14.     CMP R0, #1
  15.     BNE loop
  16.     B exit
  17.  
  18. loop:
  19.     STR R4, [R1], #4    @ Store element in array
  20.  
  21.     AND R6, R3, R5      @ R6 = R3 % R5
  22.     AND R8, R4, R5      @ R8 = R4 % R5
  23.     MUL R9, R6, R8      @ R9 = R6 * R8
  24.     AND R4, R9, R5      @ R4 = R9 % R5
  25.    
  26.     MOV R3, R4
  27.  
  28.     ADD R4, R4, #1      @ R4 + 1
  29.     AND R4, R4, R5      @ R4 % R5
  30.  
  31.     SUB R0, R0, #1      @ Number of elements--
  32.    
  33.     B check             @ Return to check section
  34.  
  35. exit:
  36.     LDR R1, =array
  37.  
  38.     LDR R2, [R1]        @ Load elements from array in registers to see their values
  39.     LDR R3, [R1, #4]    @ Load elements from array in registers to see their values
  40.     LDR R4, [R1, #8]    @ Load elements from array in registers to see their values
  41.     LDR R5, [R1, #12]   @ Load elements from array in registers to see their values
  42.     LDR R6, [R1, #16]   @ Load elements from array in registers to see their values
  43.     LDR R8, [R1, #20]   @ Load elements from array in registers to see their values
  44.  
  45.     MOV R7, #1          @ Terminate syscall with status 1
  46.     SWI 0               @ Execute syscall
  47.  
  48. largeNum:
  49.     .word 1000000007
  50.  
  51. .data
  52.     array: .word 0, 0, 0, 0, 0, 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement