# Memory Execute

### Signature

```c
int tim_memoryExecute(int callAddress, int/float arg1, int/float arg2, int/float arg3, int/float arg4); //id:0x1002
```

### Description

Executes the call address with the provided arguments.

* The first four integer or pointer arguments are passed in the ecx, edx, r8d and r9d registers.
* The first four floating-point arguments are passed in the first four SSE registers, xmm0-xmm3.
* Any additional arguments are passed on the stack via the [memory-push-stack](memory-push-stack "mention") function.
* Forwards the integer or pointer value returned in the eax register from the called function.

### Examples

#### Parameter Passing

```c
function allInt()
{
    regI0 = 1; //ecx
    regI1 = 2; //edx
    regI2 = 3; //r8d
    regI3 = 4; //r9d
    tim_memoryPushStack(5); //rsp+24
    tim_memoryPushStack(6); //rsp+28
    tim_memoryExecute(0x00000000, regI0, regI1, regI2, regI3); 
}

function allFloat()
{
    regF0 = 1.0; //xmm0
    regF1 = 2.0; //xmm1
    regF2 = 3.0; //xmm2
    regF3 = 4.0; //xmm3
    tim_memoryPushStack(5.0); //rsp+24
    tim_memoryPushStack(6.0); //rsp+28
    tim_memoryExecute(0x00000000, regF0, regF1, regF2, regF3);
}

function mixed()
{
    regI0 = 1; //ecx
    regF1 = 2.0; //xmm1
    regI2 = 3; //r8d
    regF3 = 4.0; //xmm3
    tim_memoryPushStack(5); //rsp+24
    tim_memoryPushStack(6.0); //rsp+28
    tim_memoryExecute(0x00000000, regI0, regF1, regI2, regF3);
}
```

#### Set All Party Members To Max Level

```c
for (regI0 = 0; regI0 < 40; regI0++)
{
    regI1 = tim_memoryExecute(0x00320A40, regI0, 0, 0, 0); //getBattleUnitKeep(...)
    regI2 = 99 //level
    tim_memoryExecute(0x0030C470, regI1, regI2, 0, 0); //setStats(...)
}
```

### Notes

{% hint style="danger" %}
Since the call address nor the arguments passed to it can be verified by the VM extension itself, the responsibility falls completely to the user to handle both correctly. Failure to do so will otherwise result in a game crash.
{% endhint %}
