Assembly program to Add two numbers

In this post, we will show a simple program which adds two numbers from two registers and save it into third register. So this program does following,

  • Copy first number (ex. decimal 6) to register R0
  • Copy second number (ex. decimal 3) to register R1
  • Add those two numbers from register R0 and R1 (6+3) and save the addition to register R2 (ex. decimal 9)

So, the final program would look as,

MOVS R0, #6
MOVS R1, #3
ADDS R2, R1, R0

Note: This instructions works for ARM.

Leave a Comment