Difference between revisions of "Call arguments"

From Final Fantasy XII Wiki
Jump to navigation Jump to search
(Created page with "All arguments for called functions are pushed onto stack in order of appearance in function signature. In other words, top of the stack contains the last argument. E.g. a c-l...")
 
Line 1: Line 1:
 
All arguments for called functions are pushed onto stack in order of appearance in function signature. In other words, top of the stack contains the last argument.
 
All arguments for called functions are pushed onto stack in order of appearance in function signature. In other words, top of the stack contains the last argument.
  
E.g. a c-like call<syntaxhighlight lang="c++">
+
E.g. a c-like call
 +
<syntaxhighlight lang="c++">
 
setpos(posx, posy, posz);
 
setpos(posx, posy, posz);
</syntaxhighlight>Is represented by<syntaxhighlight lang="asm">
+
</syntaxhighlight>
 +
Is represented by
 +
<syntaxhighlight lang="asm">
 
PUSHV [posx]
 
PUSHV [posx]
 
PUSHV [posy]
 
PUSHV [posy]
 
PUSHV [posz]
 
PUSHV [posz]
 
CALLPOPA [setpos]
 
CALLPOPA [setpos]
 +
</syntaxhighlight>
 +
If a function is called within a context of another script, different instruction is used and additional value (representing script number) is pushed onto the stack.
 +
E.g. a c-like call
 +
<syntaxhighlight lang="c++">
 +
NPC01.setpos(posx, posy, posz);
 +
</syntaxhighlight>
 +
Is represented by
 +
<syntaxhighlight lang="asm">
 +
PUSHV [posx]
 +
PUSHV [posy]
 +
PUSHV [posz]
 +
PUSHII 2  #where 2 is script number
 +
CALLACTPOPA [setpos]
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 14:05, 16 July 2019

All arguments for called functions are pushed onto stack in order of appearance in function signature. In other words, top of the stack contains the last argument.

E.g. a c-like call

setpos(posx, posy, posz);

Is represented by

PUSHV [posx]
PUSHV [posy]
PUSHV [posz]
CALLPOPA [setpos]

If a function is called within a context of another script, different instruction is used and additional value (representing script number) is pushed onto the stack. E.g. a c-like call

NPC01.setpos(posx, posy, posz);

Is represented by

PUSHV [posx]
PUSHV [posy]
PUSHV [posz]
PUSHII 2   #where 2 is script number
CALLACTPOPA [setpos]