Advertisement
myersjo

Unique

Nov 30th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 1.06 KB | None | 0 0
  1.     AREA    Unique, CODE, READONLY
  2.     IMPORT  main
  3.     EXPORT  start
  4.  
  5. start
  6.  
  7.     LDR R1, =VALUES
  8.     LDR R2, =COUNT
  9.     LDR R2, [R2]            ; load number of values from string COUNT  
  10.    
  11. whValues
  12.     CMP R2, #0              ; while (count != 0)
  13.     BEQ endWhValues         ; {
  14.     LDRB R0, [R1]           ;   load currentNumber
  15.     ADD R1, R1, #4          ;   address = address + 4
  16.     LDRB R4, [R1]           ;   load nextNumber
  17.     SUB R2, R2, #1          ;   count = count - 1
  18.     MOV R3, R2              ;   count2 = count
  19.  
  20. uniqueNumber
  21.     CMP R3, #0              ;   while (count2 != 0)
  22.     BEQ whValues            ;       AND
  23.     CMP R0, R4              ;       while (currentNumber != nextNumber)
  24.     BEQ notUnique           ;   {
  25.     MOV R5, R1              ;       copy address of values from curent pointer
  26.     LDRB R5, [R5]           ;       load value at current pointer
  27.     ADD R4, R5, #4          ;       address = address + 4
  28.     SUB R3, R3, #1          ;       count2 = count2 - 1
  29.     B uniqueNumber          ;   }
  30.  
  31.    
  32. endWhValues
  33.     LDR R0, =1              ; if (unique)
  34.     B stop                  ;   R0 = 1
  35.    
  36. notUnique
  37.     LDR R0, =0              ; if (!unique)
  38.     B stop                  ;   R0 = 0
  39.    
  40.    
  41. stop    B   stop
  42.  
  43.  
  44.     AREA    TestData, DATA, READWRITE
  45.    
  46. COUNT   DCD 10
  47. VALUES  DCD 5, 2, 7, 18, 4, 13, 4, 18, 8, 9, 12
  48.  
  49.  
  50.     END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement