Arm/loadexec

From ASMBits

Write a function that will copy a block of code (assumed to be a function) to a given location in memory, then call the function, passing it one integer parameter.

void loadexec( int(*dest)(int), int(*src)(int), unsigned int code_length, int param);

The block of code is located at location src, with length code_length bytes. This block of code should be copied to dest. After copying, execute the code at dest and pass it parameter param, and returning its return value (i.e., with dest as a function pointer, do return dest(param))

Expected solution length: Around 10 lines.

Sample Input

[See below]

Sample Output

r0=8

Due to the stringent debug checks used by this simulator, don't use pop {pc} unless the intention is to return from a function.

Write your solution here

Upload a source file...