User:Erik G/Sandbox 2
From RISC OS
Jump to navigationJump to search
APCS-compatible assembler routines
Sometimes the need arises for a programmer to write part of the program in assembler. Maybe to get the best speed in some inner loop, maybe because the job can only be done in assembly, maybe there is a chunk of assembly code for which it is too much trouble to convert it to C.
There are two ways to include assembly code in a C program:
- Directly, using #pragma asm. This is tricky and dangerous.
- As an APCS compatible routine. This can be compiled (assembled) separately and then linked with the rest of the code.
- why not #pragma
Don't know where variables are. Check requires producing assembly code and hand-analysing it. May need to be changed when a new version of the compiler is used.
The Acorn Procedure Call Standard
reference to documentation
General routine
Stack
Routine entry and exit
Leaf routines
Parameters
- 4 or less
- more than 4
- floating point
R14
When is it available and when is it not.
Assembler directives
- Code areas (?)
- Data areas (?)
- declarations of symbols
Compiling
- commands to assemble the code and to link with the rest
- sample setup of a Makefile