System call

The system call instruction supports special, ``OS-like'' calls that provide useful services to assembly language programs. These calls work by putting a ``system call ID'' value into register $1 and the argument to the call in register $2 and then executing the syscall instruction. The result of the instruction (if any) is placed into register $1. While it may take multiple instructions to fill the registers for the system call, actually executing the system call is an atomic operation.

The DCoreWars engine MUST support the following system calls:

System calls available in the DCoreWars game engine. All system calls are available on both uniprocessor and distributed versions of the game, but a distributed system call (e.g., RemoteProc(RPGID)) called in a uniprocessor game has no effect.
Syscall ID ($1) Argument ($2) Description
0 none HALT -- equivalent to the hlt instruction
1 none Random -- return a random, unsigned integer in the range $ [0\dotsb 2^{32}-1]$.
2 none Memsize -- return the memory size of the RVM on which the instruction is executed
3 none Netsize -- return the number of hosts on the current network
4 none GetPID -- return a unique identifier for the currently executing PROCESS
5 none GetPGID -- return a unique identifier for the currently executing PROCESS GROUP
6 none GetNPG -- return the number of RUNNABLE PROCESS GROUPs on the current RVM
7 none GetNPlayers -- return the number of players in the current game
8 PGID Score(PGID) -- return the current score (number of memory cells owned by) the specified PROCESS GROUP
9 RPGID RemoteProc(RPGID) -- return 1 if the specified PROCESS GROUP is RUNNABLE on the remote host currently connected to the SOCKET of the executing PROCESS, or 0 otherwise. Invoking this system call when the current SOCKET is empty (not yet connected or connection terminated) returns 0.
10 RPGID RemoteScore(RPGID) -- return the score (number of memory cells owned by) the specified PROCESS GROUP on the remote host currently connected to the SOCKET of the executing PROCESS. Invoking this system call when the current SOCKET is empty (not yet connected or connection terminated) returns 0.
11 PGID GetNProcs(PGID) -- return the number of RUNNABLE PROCESSes in the specified PROCESS GROUP.
     

The implementors are free to provide additional system calls, at their option, but all such system calls MUST be fully documented. Invoking an undocumented system call is an ILLEGAL OPERATION for the invoking process.

Terran Lane 2004-03-29