11.3 Register call functions

-----------------------------

A register function is defined by default using an identifier which

does not contain lower-case letters, or by clearly indicating that this is

a register function using the keyword fastcall.

As already noted, the parameters (if there are any) for a register

function are transferred via the registers. Register functions can have no

more than 6 parameters. If the parameters are of type 'int' or 'word', the

registers are by default used in the following order: AX, BX, CX, DX, DI,

SI. The first four parameters can also be of type 'char' or 'byte', in

which case registers AL, BL, CL and DL are activated. Any of the six

parameters may be of type 'long', 'dword' or 'float', in which case the

registers used are EAX, EBX, ECX, EDX, EDI or ESI.

In the following example, a register function named TOGETHER returns a

value of type 'word' as a result of multiplying the first parameters of

type 'word' by the second parameter of the same type.

word TOGETHER() /* AX = first parameter, BX = second parameter */

{

return (AX * BX);

}

In the following example a register function named SHOW_NUM, does not

return any value but instead prints to the screen the first parameter (of

type 'int'), a separator ':', and then the second parameter (of type

'byte').

void SHOW_NUM () /* AX = first number, BL = second number */

{

$ PUSH BX

WRITEINT (int AX);

WRITE (':');

$ POP BX

WRITEWORD (BL);

}

If, however, a function contains a declaration of the order and types

of the registers used, any desired use may be made of the registers. You

can read more about this in the chapter on declarations of paramters in

register functions.

For a register function to be used as a macro, it must be declared as a

dynamic function. Dynamic functions are described in the next chapter.