1 package com.tapina.robe.swi.clib.stdlib;
2
3 import com.tapina.robe.swi.clib.Stub;
4 import com.tapina.robe.runtime.RawDataBlock;
5 import com.tapina.robe.runtime.Environment;
6
7 /***
8 * This function allocates space for a1 objects, with each object taking a2 bytes.
9 * The total space allocated is therefore (a1*a2) bytes. The entire space is initialised with each byte zeroed.
10 * Returns: Pointer to space, or NULL if failed (never fails).
11 */
12 public class CAlloc extends Stub {
13 public void executeStub(Environment environment) {
14 final int[] R = environment.getCpu().R;
15 final RawDataBlock block = environment.getMemoryMap().createSystemDataBlock(R[0] * R[1]);
16 R[0] = block.getAddress();
17 }
18 }