| AngelScript |

Byte code instructions

This page gives a brief description of each of the byte code instructions that the virtual machine has.

- Object management
- Math instructions
- Bitwise instructions
- Comparisons
- Type conversions
- Increment and decrement
- Flow control
- Stack and data management
- Global variables
- Initialization list management

# Object management

Perform a bitwise copy of a memory buffer to another

- asBC_COPY

Push the address and length of a string on the stack

- asBC_STR

Allocate the memory for an object and setup the VM to execute the constructor

- asBC_ALLOC

Release the memory of an object or list buffer

- asBC_FREE

Move the address in an object variable to the object register. The address in the variable is then cleared.

- asBC_LOADOBJ

Move the address from the object register to an object variable. The address in the object register is then cleared.

- asBC_STOREOBJ

Copy the object handle from one address to another. The reference count of the object is updated to reflect the copy.

- asBC_REFCPY

Copy the object handle on stack to a handle in a variable. The reference count of the object is updated to reflect the copy.

- asBC_RefCpyV

Push the pointer of an object type on the stack

- asBC_OBJTYPE

Push the type id on the stack

- asBC_TYPEID

Pop an address to a script object from the stack. If the desired cast can be made store the address in the object register.

- asBC_Cast

Push the function pointer on the stack

- asBC_FuncPtr

Load the address to a property of the object into the value register. Substitutes the sequence PshV4/8, ADDSi, PopRPtr.

- asBC_LoadThisR
- asBC_LoadRObjR

Load the address to a property of a value object into the value register. Substitutes the sequence PSF, ADDSi, PopRPtr.

- asBC_LoadVObjR

# Math instructions

Negate the value in the variable. The original value is overwritten.

- asBC_NEGi
- asBC_NEGf
- asBC_NEGd
- asBC_NEGi64

Perform the operation with the value of two variables and store the result in a third variable.

- asBC_ADDi
- asBC_SUBi
- asBC_MULi
- asBC_DIVi
- asBC_MODi
- asBC_POWi
- asBC_POWu
- asBC_ADDf
- asBC_SUBf
- asBC_MULf
- asBC_DIVf
- asBC_MODf
- asBC_POWf
- asBC_ADDd
- asBC_SUBd
- asBC_MULd
- asBC_DIVd
- asBC_MODd
- asBC_POWd
- asBC_POWdi
- asBC_ADDi64
- asBC_SUBi64
- asBC_MULi64
- asBC_DIVi64
- asBC_MODi64
- asBC_POWi64
- asBC_POWu64

Perform the operation with a constant value and the value of the variable. The original value is overwritten.

- asBC_ADDIi
- asBC_SUBIi
- asBC_MULIi
- asBC_ADDIf
- asBC_SUBIf
- asBC_MULIf

# Bitwise instructions

Perform a boolean not operation on the value in the variable. The original value is overwritten.

- asBC_NOT

Perform a bitwise complement on the value in the variable. The original value is overwritten.

- asBC_BNOT
- asBC_BNOT64

Perform the operation with the value of two variables and store the result in a third variable.

- asBC_BAND
- asBC_BOR
- asBC_BXOR
- asBC_BAND64
- asBC_BOR64
- asBC_BXOR64
- asBC_BSLL
- asBC_BSRL
- asBC_BSRA
- asBC_BSLL64
- asBC_BSRL64
- asBC_BSRA64

# Comparisons

Compare the value of two variables and store the result in the value register.

- asBC_CMPi
- asBC_CMPu
- asBC_CMPf
- asBC_CMPd
- asBC_CMPi64
- asBC_CMPu64
- asBC_CmpPtr

Compare the value of a variable with a constant and store the result in the value register.

- asBC_CMPIi
- asBC_CMPIu
- asBC_CMPIf

Test the value in the value register. Update the value register according to the result.

- asBC_TZ
- asBC_TNZ
- asBC_TS
- asBC_TNS
- asBC_TP
- asBC_TNP

# Type conversions

Convert the value in the variable. The original value is overwritten.

- asBC_iTOb
- asBC_iTOw
- asBC_sbTOi
- asBC_swTOi
- asBC_ubTOi
- asBC_uwTOi
- asBC_iTOf
- asBC_fTOi
- asBC_uTOf
- asBC_fTOu
- asBC_dTOi64
- asBC_dTOu64
- asBC_i64TOd
- asBC_u64TOd

Convert the value of a variable and store the result in another variable.

- asBC_dTOi
- asBC_dTOu
- asBC_dTOf
- asBC_iTOd
- asBC_uTOd
- asBC_fTOd
- asBC_i64TOi
- asBC_i64TOf
- asBC_u64TOf
- asBC_uTOi64
- asBC_iTOi64
- asBC_fTOi64
- asBC_fTOu64

# Increment and decrement

Increment or decrement the value pointed to by the address in the value register.

- asBC_INCi8
- asBC_DECi8
- asBC_INCi16
- asBC_DECi16
- asBC_INCi
- asBC_DECi
- asBC_INCi64
- asBC_DECi64
- asBC_INCf
- asBC_DECf
- asBC_INCd
- asBC_DECd

Increment or decrement the value in the variable.

- asBC_IncVi
- asBC_DecVi

# Flow control

Setup the VM to begin execution of the other script function

- asBC_CALL
- asBC_CALLINTF
- asBC_CALLBND
- asBC_CallPtr

Setup the VM to return to the calling function

- asBC_RET

Make an unconditional jump to a relative position

- asBC_JMP

Make a jump to a relative position depending on the value in the value register

- asBC_JZ
- asBC_JNZ
- asBC_JS
- asBC_JNS
- asBC_JP
- asBC_JNP
- asBC_JMPP
- asBC_JLowZ
- asBC_JLowNZ

Call an application registered function

- asBC_CALLSYS
- asBC_Thiscall1

Save the state and suspend execution, then return control to the application

- asBC_SUSPEND

Give control of execution to the JIT compiled function

- asBC_JitEntry

# Stack and data management

Push a constant value on the stack.

- asBC_PshC4
- asBC_PshC8
- asBC_PshNull

Push the stack frame pointer on the stack.

- asBC_PSF

Swap the top values on the stack.

- asBC_SwapPtr

Dereference top pointer on stack. Raises exception if pointer is null.

- asBC_RDSPtr

Add an offset to the top address on the stack. Raises exception if address is null.

- asBC_ADDSi

Push the value of a variable on the stack.

- asBC_PshV4
- asBC_PshV8
- asBC_PshVPtr

Initialize the value of a variable with a constant.

- asBC_SetV1
- asBC_SetV2
- asBC_SetV4
- asBC_SetV8
- asBC_ClrVPtr

Copy the value of one variable to another.

- asBC_CpyVtoV4
- asBC_CpyVtoV8

Validate that an expected pointer is not null.

- asBC_CHKREF
- asBC_ChkRefS
- asBC_ChkNullV
- asBC_ChkNullS

Push the variable index with the size of a pointer on the stack.

- asBC_VAR

Replace a variable index on the stack with an address.

- asBC_GETREF
- asBC_GETOBJ
- asBC_GETOBJREF

Pop and discard an address from the stack.

- asBC_PopPtr

Pop or push an address to or from the value register.

- asBC_PopRPtr
- asBC_PshRPtr

Copy a value between value register and a variable.

- asBC_CpyVtoR4
- asBC_CpyVtoR8
- asBC_CpyRtoV4
- asBC_CpyRtoV8

Copy a value from a variable to the address held in the value register

- asBC_WRTV1
- asBC_WRTV2
- asBC_WRTV4
- asBC_WRTV8

Copy a value from the address held in the value register to a variable

- asBC_RDR1
- asBC_RDR2
- asBC_RDR4
- asBC_RDR8

Load the address of the variable into the value register

- asBC_LDV

Clear the upper bytes of the value register

- asBC_ClrHi

# Global variables

Push the value of a global variable on the stack

- asBC_PshG4
- asBC_PshGPtr

Load the address of a global variable into the value register

- asBC_LDG

Load the address of a global variable into the value register and copy the value of the global variable to local variable

- asBC_LdGRdR4

Copy a value between local variable and global variable.

- asBC_CpyVtoG4
- asBC_CpyGtoV4

Push the address of the global variable on the stack.

- asBC_PGA

Initialize the variable of a global variable with a constant.

- asBC_SetG4

# Initialization list management

Allocates the memory for the initialization list buffer

- asBC_AllocMem

Sets the number of elements that will be repeated afterwards

- asBC_SetListSize

Sets the type of the next element

- asBC_SetListType

Pushes the address of the list element on the stack

- asBC_PshListElmnt