Introduction to Assembly Programming in ARM — Basic Arithmetic

Scott Cosentino
CodeX
Published in
4 min readAug 2, 2021

--

In any programming language, it is essential to know how to manipulate numeric values. In assembly, there are a number of operations available to help us add, subtract, and multiple numbers. In this article, you will learn about the different operations and see how they can be used.

Simple Arithmetic Operations

Suppose we have two numbers that we wish to add together. To achieve this, we can use the ADD instruction. The ADD instruction will take in a destination for the result, as well as two numbers to add together. The code below shows how we can load two numbers into register memory, add them, and store the result.

In addition to adding our two numbers, we could also subtract or multiply them. To subtract two numbers, we use the SUB instruction, which uses the same syntax as the ADD instruction. To multiply two numbers, we use the MUL instruction, which again uses the same syntax as ADD and SUB.

These basic instructions work well when we don’t expect there to be negative numbers, carries, or overflows. So for example, if you want to create a counter that started at 0, and incremented by 1 until the end of a list, the ADD instruction would be a…

--

--