User Tools

Site Tools


client:quest_engine

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
client:quest_engine [2019/10/07 14:36]
escu Corrected argument stack description
client:quest_engine [2019/10/10 13:53] (current)
escu Added info about which storage types are global and which are thread local
Line 14: Line 14:
 ==== Registers ==== ==== Registers ====
  
-Used for arbitrary data storage and also for providing and receiving arguments to and from opcodes. The size of each register is 4 bytes and there are 256 registers in total, numbered from 0 to 255.  A pointer to the register array can be found at 0x00A954B0.+Used for arbitrary data storage and also for providing and receiving arguments to and from opcodes. The size of each register is 4 bytes and there are 256 registers in total, numbered from 0 to 255. Registers are shared across threads. ​A pointer to the register array can be found at 0x00A954B0.
  
 ==== Call Stack ==== ==== Call Stack ====
  
-Used to store the return addresses of function calls. The opcodes ''​call''​ and ''​ret''​ operate on this stack. The call stack must be emptied before the quest script reaches its end. The size of the call stack is unknown.+Used to store the return addresses of function calls. The opcodes ''​call''​ and ''​ret''​ operate on this stack. Each thread has its own call stack. The call stack must be emptied before the quest script reaches its end. The size of the call stack is unknown.
  
 ==== Argument Stack ==== ==== Argument Stack ====
  
-Used to provide arguments for opcodes. The size of each element is 4 bytes and the maximum length of the stack is 8. The ''​arg_push*''​ opcodes add elements to this stack. An opcode that requires stack arguments will automatically fetch the arguments from the argument stack. Although the argument stack is referred to as a //stack// here, opcodes do not fetch the arguments using the common stack operation "​pop"​. Rather, they index the stack by their parameters'​ indices. There is a counter that counts the number of arguments pushed to the stack. The counter is set to zero when an opcode successfully fetches its arguments from the stack. However, opcodes do not actually care about the counter and will happily take whatever stray data is left on the stack as long as it can be interpreted as valid arguments for the opcode.+Used to provide arguments for opcodes. The size of each element is 4 bytes and the maximum length of the stack is 8. The ''​arg_push*''​ opcodes add elements to this stack. Each thread has its own argument ​stack. An opcode that requires stack arguments will automatically fetch the arguments from the argument stack. Although the argument stack is referred to as a //stack// here, opcodes do not fetch the arguments using the common stack operation "​pop"​. Rather, they index the stack by their parameters'​ indices. There is a counter that counts the number of arguments pushed to the stack. The counter is set to zero when an opcode successfully fetches its arguments from the stack. However, opcodes do not actually care about the counter and will happily take whatever stray data is left on the stack as long as it can be interpreted as valid arguments for the opcode.
  
 === Note about arg_pushs === === Note about arg_pushs ===
  
-The ''​arg_pushs''​ opcode stores its string argument in a static location then pushes the address of that location to the stack. This means that if ''​arg_pushs''​ is used multiple times consecutively the previous strings will be overwritten and only the most recent string will be stored. However, this quirk does not affect normal usage as there aren't any opcodes that require more than one string argument.+The ''​arg_pushs''​ opcode stores its string argument in a static location ​that is shared across threads. It then pushes the address of that location to the stack. This means that if ''​arg_pushs''​ is used multiple times consecutively the previous strings will be overwritten and only the most recent string will be stored. However, this quirk does not affect normal usage as there aren't any opcodes that require more than one string argument.
  
 ==== Variable Stack ==== ==== Variable Stack ====
  
-Used for arbitrary data storage. The opcodes ''​stack_push'',​ ''​stack_pushm'',​ ''​stack_pop''​ and ''​stack_popm''​ operate on this stack. The intended usage of this stack seems to be to temporarily save the values of registers so that the registers can be used for something else then restoring the registers'​ values after the work is done. The size of each element is 4 bytes and the maximum length of the stack is unknown.+Used for arbitrary data storage. The opcodes ''​stack_push'',​ ''​stack_pushm'',​ ''​stack_pop''​ and ''​stack_popm''​ operate on this stack. Each thread has its own variable ​stack. The intended usage of this stack seems to be to temporarily save the values of registers so that the registers can be used for something else then restoring the registers'​ values after the work is done. The size of each element is 4 bytes and the maximum length of the stack is unknown.
client/quest_engine.txt ยท Last modified: 2019/10/10 13:53 by escu