There are essentially 2 ways to embed assembly code in the pascal source. The first one is the simplest, by using an asm block:
Everything between the asm and end block is inserted as assembler in the generated code. Depending on the assembler reader mode, the compiler performs substitution of certain names with their addresses.
The second way is implementing a complete procedure or function in assembler. This is done by adding a assembler modifier to the function or procedure header:
It’s still possible to declare variables in an assembler procedure:
The compiler will reserve space on the stack for these variables, it inserts some commands for this.
Note that the assembler name of an assembler function will still be ’mangled’ by the compiler, i.e. the label for this function will not be the name of the function as declared. To change this, an Alias modifier can be used:
To make the function available in assembler code outside the current unit, the Public modifier can be added: