5. Procedure (trig_vm_ex)

A cell procedure determines how to determine the bitpattern to perform a particular function. It will always return an integer, which is the next cell position to jump to. The three major parameters it takes in are current position, command word, the data word. This function parses the command word, and executes the appropriate function.

When a cell is computed, it copies it's internal words over to this function to be parsed.

There are a potential of 8 major opcode types, stored in the first 8 bits of the bytes, which correspond to 8 potential functions.

<<funcdefs>>=
int trig_vm_ex(trig_vm *vm,
               int pos,
               uint32_t cmd,
               uint32_t data);
<<funcs>>=
<<exfuncs>>
int trig_vm_ex(trig_vm *vm,
               int pos,
               uint32_t cmd,
               uint32_t data)
{
    if (cmd == 0) return empty(vm, pos, cmd, data);
    if (cmd & 1) return pattern(vm, pos, cmd, data);
    if (cmd & 2) return jump(vm, pos, cmd, data);
    if (cmd & 4) return maygate(vm, pos, cmd, data);
    if (cmd & 8) return metapattern(vm, pos, cmd, data);

    return empty(vm, pos, cmd, data);
}



prev | home | next