Nios/load

From ASMBits

nios/add64Previous

There is a 32-bit word located at memory location (address) 0x345678. Write a function that reads this word from memory and returns it. Note that the function has no parameters: It loads a word from a hard-coded location.

int load ();

Expected solution length: Around 3 lines.

Sample Input

Memory [0x345678] initialized to 123. No input to function.

Sample Output

123

Write your solution here

x
 
1
.global _start
2
_start:
3
    movia sp, 0x04000000
4
    movia r2, 0x345678
5
    movia r3, 123
6
    stw r3, 0(r2)
7
    movi r2, 0xbad   # This function has no parameters.
8
    movi r3, 0xbad   # So destroy register values here so you won't be tempted to use it.
9
    call load
10
    1: br 1b    # Done
11
12
.global load
13
load:
14
    
15
    
Upload a source file...