Emulator Functions Under Unix
The most important of the emulator's system functions are now
available for general programming under unix on rabbit. They
use only standard functions, so will probably work with other
varieties of unix too.
To make use of these functions, you should make a link to the
.h and .o files in your own directories, using these two
commands:ln -s /usr/local/simsys/stdsys.h ./stdsys.h
ln -s /usr/local/simsys/stdsys.o ./stdsys.o
You should make links, not copies. I will be updating these
files as time permits to increase functionality. If you take
a copy, you won't automatically get the updates; if you make a link, you
will.
In order to use these functions, you would write a perfectly
normal C program, and put at the beginning#include "stdsys.h"
Note that it uses quotes, not pointy brackets. If your program is
called for example filesystem.cpp, you would then compile it
with this command:CC filesystem.cpp stdsys.o -o filesystem
and if there are no errors, it will be ready to run with the command
filesystem
If you wish to see the source code, it is in /usr/local/simsys/stdsys.cpp,
but there is no reason why you should need to look at it unloess you want to.
Limitations
All of the functions
that I have made available work exactly as described in
The
Documentation for the Emulator.
In addition to the sys$... functions, there are also seven extras:
- int createdisc(int id, int numblocks);
This function creates a fake disc file suitable for use with the
sys$... functions that provide disc access. id is
the disc identification number, which must be between 0 and 9, and
numblocks is the desired number of blocks. Don't make it too big.
Returns 1 for syccess, 0 for failure.
- int syscallindex(void *function);
As described in the documentation for sys$defsys.
- double netsenderrorrate(double r);
Sets the simulated error rate for network transmissions. The
parameter r is the probability that any particular call to
sys$netsnd wail fail to cause any data to be sent.
- double netrecverrorrate(double r);
Sets the simulated error rate for network reception. The
parameter r is the probability that any particular call to
sys$netrcv wail fail to receive any data even
though data may be available.
- void special_terminal(void);
Puts the keyboard into "character break" mode, so that it
is not necessary to press ENTER before characters are
avaiulable for input. This function is called automatically
whenever sys$echo or sys$getch are used.
- void normal_terminal(void);
Reverses the effect of special_terminal. This function
should be used in any program that attempts to perform normal
keyboard input after having used sys$echo or
sys$getch.
- int get_register(int regnum);
Returns the value of the indicated general purpose CPU register.
The only real use is in interrupt handler routines, where
get_register(0) may be used to retrieve information that is
usually made available in R0.
Currently Available
- void sys$setiv(void *handler, int number);
- void sys$setti(int time);
- int sys$getch(void);
- int sys$echo(int onoroff);
- void sys$smlslp(void);
- void sys$putch(int c);
- void sys$putstr(char *s);
- int sys$dscnbl(int discn);
- int sys$dscrbl(int discn, int blockn, void *buffer);
- int sys$dscwbl(int discn, int blockn, void *buffer);
- int sys$defsys(int index, void *function);
- int sys$info(int key);
- int sys$mode(int mode);
- int sys$daytim(int *d, int *t);
- int sys$encday(int y, int m, int d);
- int sys$decday(int dn, int *y, int *m, int *d, int *w);
- int sys$sample(int x);
- int sys$getip(int addr[]);
- int sys$netsnd(int addr[], void *data, int len);
- int sys$netrcv(int addr[], void *data, int maxlen);
Not Yet Available
- int sys$open(char *filename, int mode);
- int sys$iopen(char *filename, int mode);
- int sys$close(int fileref);
- int sys$iclose(int fileref);
- int sys$seek(int fileref, int position);
- int sys$iseek(int fileref, int position);
- int sys$read(int fileref, void * buffer, int numbytes);
- int sys$iread(int fileref, void * buffer, int numbytes);
- int sys$write(int fileref, void * buffer, int numbytes);
- int sys$iwrite(int fileref, void * buffer, int numbytes);
Never to be Available
- int sys$load(char *filename);
- int sys$palloc(int ppn);
- int sys$setvmp(int vaddr, int prot, int ppn);
- int sys$getvmp(int vaddr);
- int sys$chkvmp(int vaddr);
- int sys$defsym(char *name, int value);
- int sys$chksym(char *name);
- int sys$lkpsym(char *name);
- int sys$delsym(char *name);
- int sys$getsym(int table, int index, char *name);