Arm/return

From ASMBits

Write a function named func that does nothing and simply returns.

The problems in this collection require you to write functions, rather than a program that simply ends with an infinite loop, unlike some other assembly programming exercises you may have seen. One side effect is that even your top-level function must follow calling conventions, and will need to save/restore registers as necessary.

If your function correctly returns, the test output will show Test completed. Otherwise, it shows Test did not complete.

We usually show you the results of a few easy test cases, but we keep some of the harder test cases secret and show only Correct/Incorrect.

The code following the _start label is for your convenience in writing a program to test your function. There will usually be an example test case written for you to get a feel for what the test input is. Use it as a starting point to test more challenging test input. The _start label is not used when judging: the test code directly calls your function.

Expected solution length: Around 1 line.

Sample Input

[No input]

Sample Output

[No output] 

ARM has several common ways to return from a function:

  • mov pc, lr
  • bx lr
  • push {lr} ; ... ; pop {pc}

The ARMv7-A Architecture Reference Manual (section A4.1.1) recommends against using the first option because it can only switch modes from ARM to Thumb, while the latter two can switch processor modes in both directions.

Write your solution here

Upload a source file...