/* * Source name : ex1_asmprog.s * Executable name : ex1_asmprog * Author : Jason Fritts * Description : Compares two numbers and sets r0 to 1 if equal * * Build using these commands: * as --gstabs ex1_asmprog.s -o ex1_asmprog.o * gcc -g ex1_asmprog.o -o ex1_asmprog */ .text .global main // program entry point main: push {lr} // Create stack frame push {r4} // Save r4 // start program code mov r1, #5 mov r4, #5 cmp r1, r4 bne false mov r0, #0 b end false: mov r0, #1 // run 'echo $?' after execution to see value end: // end program code pop {r4} // Restore r4 pop {pc} // Exit & return control to OS .section .rodata // read-only (e.g. string) data .section .data // initialized data .section .bss // uninitialized data