/* * Adds the constants 2 and 5 together. It then stores the sum to * memory address 0. * * Copyright(c) 2019-2021,2023 Jason Tang * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ /* entry point into program */ movi R0, #2 movi R1, #5 bl R7, adder /* write result to memory address 0 */ movi R2, #0 stwi R0, R2, #0 halt 0x1 /* * This function adds two values, then returns the sum. It is * equivalent to this C function: * unsigned adder(unsigned a, unsigned b) { * return a + b; * } * * As a reminder, ULNAv2-B uses this calling convention: * R0 - holds first function parameter, and holds return value * R1 - holds second function parameter * R7 - link register (holds return address) */ adder: add. R0, R0, R1 br R7