Naked
Write functions without prolog/epilog code
Syntax
`
Sub identifier Naked [calling_convention] ( param_list )
asm_statements
End Sub
Function identifier Naked [calling_convention] ( param_list ) As data_type
asm_statements
End Function
`
Parameters
`identifier` - name of the procedure.
`calling_convention` - calling convention of the procedure - can be `cdecl`, `pascal`, or `stdcall`
`asm_statements` - the code in the procedure body. The code for handling parameters and returning values must all be done manually. Note that the methods for doing these can change, depending on the calling convention.
`param_list` - parameters to be passed to the procedure.
`data_type` - the data type of the function.
Description
`Naked` allows the programmer to write procedures without the compiler generating any prolog/epilog code. This is useful when writing small, fast functions in `Asm` without any unnecessary overhead.
Example
`
'' Naked cdecl function
Function add naked cdecl _
( _
ByVal a As Integer, _
ByVal b As Integer _
) As Integer
Asm
mov eax, dword Ptr [esp+4] '' a
add eax, dword Ptr [esp+8] '' + b
ret '' return result in eax
End Asm
End Function
Print add( 1, 5 )
`
Platform Differences

- The default calling convention can change depending on the platform used. Additionally, `stdcall` does not behave the same on all platforms - on Linux, it behaves like `cdecl`. It may be necessary to check the Intrinsic Defines (such as `__FB_WIN32__`), and write different code depending on them.

Differences from QB

- New to FreeBASIC

See also

- `Asm`
- `Function`
- `Sub`
- `cdecl`
- `pascal`
- `stdcall`