FUNCTION CALLS


SYNTAX

NAME:sym[SIZE:jsize] "[" [["sav:"] PARAMETERS:args] "]"


MEANING

  1. If sav: is declared, stores the RL1 registers (declared in the function definition) in the stack.
  2. Loads PARAMETERS into RL1.
  3. Executes the function NAME.
  4. If sav: is declared, the RL1 registers are restored.


NOTES

  1. A function can be called only as source argument of an assembly instruction or ESA construction.
  2. SIZE is the size to be used for the bsr (default: none).
  3. When SIZE is .l, the instruction jsr is used instead of bsr.l to easily allow calls to other code sections.
  4. When sav: is specified make sure that OUT (returned by the function), is not a register included in RL1.
  5. Be extremely cautious when calling functions inside ESA constructions, as some variables/registers could be accidentally trashed.
  6. Normally the speed overhead is very little (sometimes there is none at all).


EXAMPLE 1

ESA
           move.w     SetDMA.l[#$f],OldDMA
           ...
           move.w     SetDMA[sav:#$f],OldDMA
assembly
           move.w     #$f,d0           ;load parameter
           jsr        f0000000         ;execute function
           move.w     d0,OldDMA        ;store first result - OK
           ...
           movem.l    d0,-(sp)         ;preserve RL1 registers
           move.w     #$f,d0           ;load parameter
           bsr        f0000000         ;execute function
           movem.l    (sp)+,d0         ;restore RL1 registers
           move.w     d0,OldDMA        ;store second result - WRONG
(SetDMA[] is defined here.)


EXAMPLE 2

ESA
           bool #24 = GetMess[],d7
assembly
           bsr        f0000002         ;execute function
           cmpi.b     #24,MessAmount   ;evaluate boolean expression
           seq.b      d7               ;and set result
(GetMess[] is defined here.)



home