ARM Assembly code to find number of positive numbers in an array

Let’s see how to write a ARM assembly code to find number of positive numbers in an array.

ALGORITHM

  1. Start
  2. Load the base address of array.
  3. Initialize a counter register to number of elements in array.
  4. Initialize a register(Rd) to zero to store number of positive numbers.
  5. Load the value from array to a temporary register.
  6. Compare the value with zero
    • If zero flag is not set, increment to register Rd.
    • Else decrement the counter register and jump to step 5.
  7. Repeat steps 5-6 till counter value becomes zero
  8. Stop

Here is a example code to find number of positive numbers in an array.
Note: initialize the array at the end of program without fail, before execution.

CODE

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisment ad adsense adlogger