Created
May 8, 2014 03:11
-
-
Save bradfordbarr/e107a74fe691ff384990 to your computer and use it in GitHub Desktop.
Adding two numbers using ARM assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assembly generally has three sections in the source | |
// .text - This is where all of the code lives (Flash) | |
// .data - This is where all variables with value go (RAM) | |
// .bss - This is where uninitialized variables go (RAM) | |
// | |
// Since this program is super simple I just used the .text section | |
.text | |
.word 0x20000000 // (address 0x0000.0000) This initializes the stack pointer | |
b start + 1 // (address 0x0000.0004) This instructs the CPU to branch to start at reset | |
start: | |
mov r0, #1 // Move the number 1 into register r0 | |
mov r1, #2 // Move the number 2 into register r1 | |
add r2, r1, r0 // Add r0 and r1 and store the result in r2 | |
stop: b stop // Just loop forever |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment