[Oberon] trace prints
Wim Niemann
niemannw at xs4all.nl
Sun Mar 10 15:53:13 CET 2019
On Sun, 10 Mar 2019 14:28:29 +0000
"Skulski, Wojciech" <skulski at pas.rochester.edu> wrote:
> What is Norebo, which you are importing?
Project Norebo is an Oberon emulator, https://github.com/pdewacht/project-norebo
Instead of a pure emulation of the hardware, module Norebo connects to functions which are handled by the emulator to provide host services like halt and file I/O. This is an elegant approach if you work on a host OS.
CONST sysreq = -4; sysarg1 = -8; sysarg2 = -12; sysarg3 = -16;
VAR res*: INTEGER;
PROCEDURE SysReq*(req, arg1, arg2, arg3: INTEGER);
BEGIN
SYSTEM.PUT(sysarg1, arg1);
SYSTEM.PUT(sysarg2, arg2);
SYSTEM.PUT(sysarg3, arg3);
SYSTEM.PUT(sysreq, req);
SYSTEM.GET(sysreq, res)
END SysReq;
The emulator performs the requested function when address 'sysreq' is written.
In my adaptation, I added the noreboPrint request (shown below), which does not exist in Project Norebo.
Wim
#define check(expr) if(!(expr)) check_impl (__FILE__, __LINE__)
#define check_FALSE() check_impl (__FILE__, __LINE__)
void pf (char *text, ...)
{
va_list ap;
va_start(ap, text);
vfprintf (stdout, text, ap);
va_end (ap);
}
void check_impl (char *filenm, int line_nr)
{
pf ("Internal check failed in %s line %d\n", filenm, line_nr);
exit (1);
}
static uint32_t norebo_print (uint32_t adr, uint32_t _2, uint32_t _3) {
int len;
char *s;
len = (uint32_t) strlen((char *)mem + adr); check (len <= 400);
s = (char *)mem + adr;
while (*s) { if (*s == 0x0d) { *s = 0x0a; } s++; }
len = (uint32_t) write (1, (char *)mem + adr, len);
return 0;
}
More information about the Oberon
mailing list