NSIM - an HP-41 simulator
Copyright 1995 Eric L. Smith (eric@telebit.com)
$Header: /usr/home/kolwynia/eric/hpcalc/nasm/RCS/README,v 1.5 1995/08/21 22:08:46 eric Exp eric $

This package is essentially useless without HP-41 ROM images, which I
currently can't provide because they are copyrighted by Hewlett-Packard.

-----------------------------------------------------------------------------

Notices

NSIM is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License version 2 as published by the Free
Software Foundation.  Note that I am not granting permission to redistribute
or modify NSIM under the terms of any later version of the General Public
License.

This program is distributed in the hope that it will be useful (or at least
amusing), but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Public License for more details.

You should have received a copy of the GNU General Public License along with
this program (in the file "COPYING"); if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

-----------------------------------------------------------------------------

NSIM is a simulator for the hardware of the HP-41 series of calculators.
Currently it is capable of simulating the HP-41C and HP-41CV.  It should be
trivial to make it simulate the HP-41CX.  The HP-10C, HP-11C, HP-12C, HP-15C,
and HP-16C can probably be simulated with some additional work.

NSIM currently uses the X window system, although by replacing the file xio.c
with an alternate file that implements the three functions whose prototypes
are in xio.h, it should be possible to make it work with any reasonable
input and output devices.

Since NSIM simulates the actual hardware, it is of little use unless you have
an image of the ROM code from the calculator, which I can't supply.  The
ROM images is expected to be in the form of an assembly (or disassembly)
listing in which each line starts with an address of four hexadecimal digits,
a space, an object code word of three hexadecimal digits, and another space.
The rest of the line typically would contain the source code line or
disassembly, although NSIM doesn't use it for anything except display in
trace mode.

The means I used to dump the ROMs in my HP-41C to use with NSIM required a
ZENROM module, an HP-IL interface module, and an HP-IL/RS-232 interface.  I
executed the MANIO function of the HP-IL module in order to force it to use
the RS-232 interface as a printer, and set flag 15 for trace mode.  I then
used the MCED function of the ZENROM to output a disassembly listing to the
"printer", which I used Kermit to capture on my Linux box.

NSIM uses a single command line argument to specify the assembly listing file.
If no argument is found, NSIM will try to find a file using the concatentation
of the name under which it was invoked and ".lst".  This allows you to (for
instance) link NSIM to "hp41" and have it automatically try to load and run
"hp41.lst".

There is one compile time option currently defined in the Makefile:

-DUSE_TIMER
	Enables the code to use the BSD-style interval timer to prevent the
	simulator from executing more than 67 microinstructions every 1/100
	of a second.  This allows for an approximation of the performance of
	the real HP calculator.  If your operating system doesn't support
	the setitimer() system call you'll have to take this define out or
	write equivalent code yourself.  With this define in place, NSIM uses
	sufficiently little CPU time that it isn't a problem to leave it
	running all the time (at least on my DX4-100, a VAX-11/725 might be a
	different story).  It doesn't make any noticable contribution to the
	load average under Linux.  Under BSDI/386 the load average must be
	computed wrong (or at least differently), as it pegs the load average
	at one (when nothing else is running).
