mirror of
https://github.com/simh/simh.git
synced 2026-01-25 19:56:25 +00:00
scelbi: New SCELBI (SCientic-ELectronics-BIology) Simulator from Hans-Åke Lund
This commit is contained in:
139
Intel-Systems/scelbi/scelbi.txt
Normal file
139
Intel-Systems/scelbi/scelbi.txt
Normal file
@@ -0,0 +1,139 @@
|
||||
SCELBI Sumulator with Intel 8008 CPU
|
||||
====================================
|
||||
|
||||
1. Background.
|
||||
|
||||
The SCELBI (SCientic-ELectronics-BIology) computer was probably
|
||||
the first commercially available micro-computer marketed toward hobbyist.
|
||||
The first market announce for SCELBI-8H was a tiny advertisement in the
|
||||
back of the March 1974 issue of QST, an amateur radio magazine.
|
||||
The computer was built around the Intel 8008 architecture. There were two
|
||||
versions of the SCELBI. The first version was called the 8H. The H standing
|
||||
for hobbyist. The second version was called the 8B, the B standing for
|
||||
business. It had all the features of the 8H, but added support for up
|
||||
to 16K of memory. As the default memory configuration for the SCELBI simulator
|
||||
is 16K, it is really a SCELBI-8B that is simulated. More information about the
|
||||
SCELBI computer can be found at: http://www.willegal.net/scelbi/scelbi.html
|
||||
and http://history-computer.com/ModernComputer/Personal/Scelbi.html.
|
||||
|
||||
2. Hardware
|
||||
|
||||
We are simulating a SCELBI-8B from about 1975, with the following
|
||||
configuration:
|
||||
|
||||
device simulates
|
||||
name(s)
|
||||
|
||||
CPU SCELBI-8B with Intel 8008 CPU, 16KB of RAM.
|
||||
TTY Serial "bit banger" interface (commonly to an
|
||||
ASR-33), is assumed to be connected to a serial
|
||||
"glass TTY" that is your terminal running the Simulator.
|
||||
PTR Paper Tape Reader, but not implemented yet.
|
||||
|
||||
2.1 CPU
|
||||
|
||||
You may select different memory sizes, the default size is 16K.
|
||||
|
||||
SET CPU 4K
|
||||
SET CPU 8K
|
||||
SET CPU 12K
|
||||
SET CPU 16K
|
||||
|
||||
CPU Registers include the following:
|
||||
|
||||
name size comments
|
||||
|
||||
PC 14 The Program Counter
|
||||
A 8 The accumulator
|
||||
B 8 The B register.
|
||||
C 8 The C register.
|
||||
D 8 The E register.
|
||||
E 8 The E register.
|
||||
HL 16 The HL register pair. H is the top 8 bits, L is
|
||||
the bottom 8 bits.
|
||||
SP 3 Stack Pointer to return address in stack.
|
||||
CF 1 Carry Flag.
|
||||
ZF 1 Zero Flag.
|
||||
PF 1 Parity Flag.
|
||||
SF 1 Sign Flag.
|
||||
WRU 8 The interrupt character. This starts as 005
|
||||
(Ctrl-E)
|
||||
|
||||
2.2 The TTY Serial Interface
|
||||
|
||||
This interface simulates a "bitbanger" TTY interface as
|
||||
implemented on the SCELBI computer in the SCELBAL source code.
|
||||
Inport 2 bit 7 is used as input from the TTY and Outport 2 bit 0
|
||||
is used as output to the TTY. In other SCELBI documentation Inport 5
|
||||
is used for input from the TTY and Outport 6 is used for output to the TTY.
|
||||
The I/O simulation routines are mapped in the i/o configuration table
|
||||
to both port variants.
|
||||
|
||||
There are also functions that support simulated I/O for
|
||||
an Intel 8008 computer built for a master thesis in 1975.
|
||||
These functions are however not mapped in the i/o configuration
|
||||
table as they conflict with the SCELBI TTY interface.
|
||||
|
||||
3. Sample Software
|
||||
|
||||
SCELBAL was called the SCientific ELementary BAsic for the 8008
|
||||
and 8080 by SCELBI Computer Consulting. SCELBAL could be run on a SCELBI
|
||||
or other 8008 based machine that had 8K of memory. SCELBAL completely
|
||||
supported floating point math with 6 digits of precision. As time went on,
|
||||
additional packages including matrix arithmetic and math functions were added.
|
||||
|
||||
SCELBAL can be downloaded from http://www.willegal.net/scelbi/scelbal.html
|
||||
there are assembler source, hex and binary images available for three
|
||||
variants of SCELBAL. The web page also includes information about SCELBAL
|
||||
and a link to a scan of the SCELBI's SCELBAL book:
|
||||
http://www.scelbi.com/files/docs/scelbal/SCELBAL.pdf
|
||||
In chapter 14 of the SCELBAL book there is a language reference.
|
||||
|
||||
To run SCELBAL on the SCELBI simulator, download the binary code from:
|
||||
http://www.willegal.net/scelbi/software/sc1.bin
|
||||
|
||||
Then start the simulator, load the code and run:
|
||||
|
||||
SCELBI simulator V4.0-0 Beta git commit id: ba447399
|
||||
sim> d pc 100
|
||||
sim> load sc1.bin
|
||||
11942 Bytes loaded.
|
||||
sim> g
|
||||
|
||||
READY
|
||||
|
||||
SCR
|
||||
|
||||
READY
|
||||
|
||||
10 A=1
|
||||
20 B=7
|
||||
30 PRINT "A + B =";
|
||||
40 PRINT A+B
|
||||
50 END
|
||||
LIST
|
||||
10 A=1
|
||||
20 B=7
|
||||
30 PRINT "A + B =";
|
||||
40 PRINT A+B
|
||||
50 END
|
||||
|
||||
READY
|
||||
|
||||
RUN
|
||||
A + B = 8.0
|
||||
|
||||
READY
|
||||
|
||||
|
||||
Simulation stopped, PC: 000103 (INP 5)
|
||||
sim> exit
|
||||
|
||||
|
||||
Some notes on SCELBAL:
|
||||
Only upper case is recognized.
|
||||
Always do SCR before entering a program, otherwise strange
|
||||
things will happen.
|
||||
The binary code at the web page above shall be loaded starting
|
||||
at address 0100. The program shall also start to run from
|
||||
address 0100.
|
||||
345
Intel-Systems/scelbi/scelbi_io.c
Normal file
345
Intel-Systems/scelbi/scelbi_io.c
Normal file
@@ -0,0 +1,345 @@
|
||||
/* scelbi_io.c: I/O for the SCELBI computer.
|
||||
|
||||
Copyright (c) 2017, Hans-Ake Lund
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
This interface simulates a "bitbanger" TTY interface as implemented
|
||||
on the SCELBI computer in the SCELBAL source code.
|
||||
Inport 2 bit 7 is used as input from the TTY and
|
||||
Outport 2 bit 0 is used as output to the TTY.
|
||||
In SCELBI documentation Inport 5 is used for input from the TTY
|
||||
and Outport 6 is used for output to the TTY.
|
||||
The I/O simulation routines are mapped to both port combinations.
|
||||
|
||||
|
||||
There are also functions that support simulated I/O for
|
||||
the Intel 8008 computer built for a master thesis in 1975.
|
||||
These functiona are however not mapped in the i/o configuration
|
||||
table as they conflict with the SCELBI TTY interface.
|
||||
Note that Inport 0 is read by the assembler code as INP 0
|
||||
Outport 0 is written by the AS Macro Assembler code as OUT 10 (octal)
|
||||
|
||||
The following i/o ports were used in this computer:
|
||||
Outport 0: used to select device for reading from Inport 0
|
||||
and writing to Outport 3.
|
||||
Inport 0: used to read external data.
|
||||
Outport 3: used to write external data.
|
||||
|
||||
Outport 1: used to save interupt state, connected to Inport 1.
|
||||
Outport 2: used to save interupt state, connected to Inport 2.
|
||||
|
||||
Inport 3: used to input data from tape-reader
|
||||
Outport 4: used to output character to printer (implemented).
|
||||
Inport 5: used to input character from keyboard (implemented).
|
||||
|
||||
Inport 4: used for status flags for the ports (Flagport).
|
||||
Flag 1 (bit 0): set to 1 when printer ready (implemented).
|
||||
Flag 2 (bit 1): set to 1 when input available from tape-reader.
|
||||
Flag 3 (bit 2): set to 1 when tape in tape-reader.
|
||||
Flag 5 (bit 4): set to 1 when character available from keyboard (implemented).
|
||||
Flag 7 (bit 6): set to 1 when the reset key on the computer is pressed.
|
||||
|
||||
Inport 7: used to start the printer motor, just using an output pulse,
|
||||
no data is read.
|
||||
|
||||
04-Sep-17 HAL Working version of SCELBI simulator
|
||||
12-Sep-17 HAL Modules restructured in "Intel-Systems" directory
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "system_defs.h"
|
||||
|
||||
/* This is the I/O configuration table. There are 8 possible
|
||||
input device addresses (octal 0 - 7) and 24 possible output
|
||||
device addresses (octal 10 - 37).
|
||||
The port numbers are specified as for the 8008 AS Macro Assembler,
|
||||
in other 8008 assemblers outport 012 (octal) may be specified as 2.
|
||||
If a device is plugged to a port it's routine
|
||||
address is here, 'nulldev' means no device is available.
|
||||
*/
|
||||
int32 ttyout_d(int32 io, int32 data);
|
||||
int32 ttyin_d(int32 io, int32 data);
|
||||
int32 prt_d(int32 io, int32 data);
|
||||
int32 kbd_d(int32 io, int32 data);
|
||||
int32 iostat_s(int32 io, int32 data);
|
||||
int32 nulldev(int32 io, int32 data);
|
||||
|
||||
struct idev dev_table[32] = {
|
||||
{&nulldev}, {&nulldev}, {&ttyin_d}, {&nulldev}, /* 000 input 0 - 3 */
|
||||
{&nulldev}, {&ttyin_d}, {&nulldev}, {&nulldev}, /* 004 input 4 - 7 */
|
||||
{&nulldev}, {&nulldev}, {&ttyout_d}, {&nulldev}, /* 010 output 8 - 11 */
|
||||
{&nulldev}, {&nulldev}, {&ttyout_d}, {&nulldev}, /* 014 output 12 - 15 */
|
||||
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 020 output 16 - 19 */
|
||||
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 024 output 20 - 23 */
|
||||
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 030 output 24 - 27 */
|
||||
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev} /* 034 output 28 - 31 */
|
||||
};
|
||||
|
||||
#define UNIT_V_ANSI (UNIT_V_UF + 0) /* ANSI mode */
|
||||
#define UNIT_ANSI (1 << UNIT_V_ANSI)
|
||||
|
||||
t_stat tty_svc (UNIT *uptr);
|
||||
t_stat tty_reset (DEVICE *dptr);
|
||||
t_stat ptr_svc (UNIT *uptr);
|
||||
t_stat ptr_reset (DEVICE *dptr);
|
||||
|
||||
/* I/O Data Structures */
|
||||
|
||||
/* TTY, TeleTYpewriter - console input/output
|
||||
*/
|
||||
UNIT tty_unit = { UDATA (&tty_svc, 0, 0), KBD_POLL_WAIT };
|
||||
|
||||
REG tty_reg[] = {
|
||||
{ ORDATA (DATA, tty_unit.buf, 8) },
|
||||
{ ORDATA (STAT, tty_unit.u3, 8) },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
MTAB tty_mod[] = {
|
||||
{ UNIT_ANSI, 0, "TTY", "TTY", NULL },
|
||||
{ UNIT_ANSI, UNIT_ANSI, "ANSI", "ANSI", NULL },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
DEVICE tty_dev = {
|
||||
"TTY", &tty_unit, tty_reg, tty_mod,
|
||||
1, 10, 31, 1, 8, 8,
|
||||
NULL, NULL, &tty_reset,
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
|
||||
/* PTR, Paper Tape Reader - not implemented yet
|
||||
*/
|
||||
UNIT ptr_unit = { UDATA (&ptr_svc, UNIT_SEQ + UNIT_ATTABLE, 0), KBD_POLL_WAIT };
|
||||
|
||||
REG ptr_reg[] = {
|
||||
{ ORDATA (DATA, ptr_unit.buf, 8) },
|
||||
{ ORDATA (STAT, ptr_unit.u3, 8) },
|
||||
{ ORDATA (POS, ptr_unit.pos, T_ADDR_W) },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
DEVICE ptr_dev = {
|
||||
"PTR", &ptr_unit, ptr_reg, NULL,
|
||||
1, 10, 31, 1, 8, 8,
|
||||
NULL, NULL, &ptr_reset,
|
||||
NULL, NULL, NULL
|
||||
};
|
||||
|
||||
/* Service routines to handle simulator functions */
|
||||
|
||||
/* Service routine for TTY - actually gets char & places in buffer
|
||||
*/
|
||||
t_stat tty_svc (UNIT *uptr)
|
||||
{
|
||||
int32 temp;
|
||||
|
||||
sim_activate (&tty_unit, tty_unit.wait); /* continue poll */
|
||||
if ((temp = sim_poll_kbd ()) < SCPE_KFLAG)
|
||||
return (temp); /* no char or error? */
|
||||
tty_unit.buf = temp & 0377; /* Save char */
|
||||
tty_unit.u3 |= 0x10; /* Set status
|
||||
Flag 5 (bit 3) == 1 */
|
||||
|
||||
/* Do any special character handling here */
|
||||
|
||||
tty_unit.pos++;
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* Service routine for Paper Tape Reader - not implemented yet
|
||||
*/
|
||||
t_stat ptr_svc (UNIT *uptr)
|
||||
{
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* Reset routines */
|
||||
|
||||
/* Reset routine for TTY
|
||||
*/
|
||||
t_stat tty_reset (DEVICE *dptr)
|
||||
{
|
||||
tty_unit.buf = 0; /* Data */
|
||||
tty_unit.u3 = 0x01; /* Status
|
||||
Flag 1 (bit 0) == 1
|
||||
printer always ready */
|
||||
sim_activate (&tty_unit, tty_unit.wait); /* activate unit */
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* Reset routine for Paper Tape Reader - not implemented yet
|
||||
*/
|
||||
t_stat ptr_reset (DEVICE *dptr)
|
||||
{
|
||||
ptr_unit.buf = 0;
|
||||
ptr_unit.u3 = 0;
|
||||
sim_cancel (&ptr_unit); /* deactivate unit */
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
/* I/O instruction handlers for the 8008 simulator.
|
||||
Called from the CPU module when an IN or OUT instruction is issued.
|
||||
Each function is passed an 'io' flag, where 0 means a read from
|
||||
the port, and 1 means a write to the port. On input, the actual
|
||||
input (io == 0) is passed as the return value,
|
||||
on output (io != 0), 'data' is written to the device.
|
||||
*/
|
||||
|
||||
/* I/O instruction handlers for the SCELBI bitbanger serial interface
|
||||
*/
|
||||
int32 ttyin_bitcntr = 0;
|
||||
int32 ttyin_charin = 0;
|
||||
|
||||
/* TTY input routine, assumes 1 start bit, 8 databits and 2 stop bits.
|
||||
the assumed number of INP instructions for each character are 9
|
||||
*/
|
||||
int32 ttyin_d(int32 io, int32 data)
|
||||
{
|
||||
int32 newbit;
|
||||
|
||||
/* if (ttyin_bitcntr != 0) {
|
||||
sim_printf("io: %d, bitcntr: %d, charin: 0%o\n",
|
||||
io, ttyin_bitcntr, ttyin_charin);
|
||||
}
|
||||
*/
|
||||
if (io != 0) { /* not an INP instruction */
|
||||
return 0;
|
||||
}
|
||||
if (ttyin_bitcntr == 0) {
|
||||
if (tty_unit.u3 & 0x10) {
|
||||
/* Character available if Flag 5 (bit 4) set */
|
||||
ttyin_charin = tty_unit.buf | 0x80; /* bit 7 always set in SCELBAL */
|
||||
tty_unit.u3 = tty_unit.u3 & 0xEF; /* Reset Flag 5 (bit 4) */
|
||||
ttyin_bitcntr = 1;
|
||||
return (0); /* start bit */
|
||||
}
|
||||
else {
|
||||
return (0x80); /* no start bit */
|
||||
}
|
||||
}
|
||||
if (ttyin_bitcntr > 7) { /* last data bit */
|
||||
if (ttyin_charin & 1)
|
||||
newbit = 0x80;
|
||||
else
|
||||
newbit = 0x00;
|
||||
ttyin_bitcntr = 0;
|
||||
return (newbit);
|
||||
}
|
||||
if (ttyin_charin & 1)
|
||||
newbit = 0x80;
|
||||
else
|
||||
newbit = 0x00;
|
||||
ttyin_bitcntr++;
|
||||
ttyin_charin = ttyin_charin >> 1;
|
||||
return (newbit);
|
||||
}
|
||||
|
||||
int32 ttyout_bitcntr = 0;
|
||||
int32 ttyout_charout = 0;
|
||||
|
||||
/* TTY output routine, assumes 1 start bit, 8 databits and 2 stop bits.
|
||||
the assumed number of OUT instructions for each character are 10
|
||||
*/
|
||||
int32 ttyout_d(int32 io, int32 data)
|
||||
{
|
||||
int32 newbit;
|
||||
|
||||
/* sim_printf("io: %d, data: 0%o, bit0: %d, bitcntr: %d, charout: 0%o\n",
|
||||
io, data, (data & 1), ttyout_bitcntr, ttyout_charout);
|
||||
*/
|
||||
|
||||
if (io == 0) { /* not an OUT instruction */
|
||||
return 0;
|
||||
}
|
||||
if ((ttyout_bitcntr == 0) && ((data & 1) == 0)) { /* start bit */
|
||||
ttyout_bitcntr = 1;
|
||||
return 0;
|
||||
}
|
||||
if (ttyout_bitcntr == 8) { /* last bit in character */
|
||||
if (data & 1)
|
||||
newbit = 0x80;
|
||||
else
|
||||
newbit = 0x00;
|
||||
ttyout_charout = ttyout_charout >> 1;
|
||||
ttyout_charout = ttyout_charout | newbit;
|
||||
if (ttyout_charout != 0224) /* avoid printing CTRL-T */
|
||||
sim_putchar(ttyout_charout & 0x7f); /* bit 7 always set in SCELBAL */
|
||||
ttyout_bitcntr++;
|
||||
return 0;
|
||||
}
|
||||
if (ttyout_bitcntr > 8) { /* stop bit */
|
||||
ttyout_charout = 0;
|
||||
ttyout_bitcntr = 0;
|
||||
return 0;
|
||||
}
|
||||
if (data & 1)
|
||||
newbit = 0x80;
|
||||
else
|
||||
newbit = 0x00;
|
||||
ttyout_charout = ttyout_charout >> 1;
|
||||
ttyout_charout = ttyout_charout | newbit;
|
||||
ttyout_bitcntr++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* I/O instruction handlers for the master thesis computer hardware.
|
||||
*/
|
||||
|
||||
/* Get status byte from Flagport
|
||||
*/
|
||||
int32 iostat_s(int32 io, int32 data)
|
||||
{
|
||||
if (io == 0)
|
||||
return (tty_unit.u3);
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Get character from keyboard
|
||||
*/
|
||||
int32 kbd_d(int32 io, int32 data)
|
||||
{
|
||||
if (io == 0) {
|
||||
tty_unit.u3 = tty_unit.u3 & 0xEF; /* Reset Flag 5 (bit 4) */
|
||||
return (tty_unit.buf | 0x80); /* bit 7 always set in SCELBAL */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Put character to printer
|
||||
*/
|
||||
int32 prt_d(int32 io, int32 data)
|
||||
{
|
||||
if (io != 0) {
|
||||
sim_putchar(data & 0x7f); /* bit 7 always set in SCELBAL */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* I/O instruction handler for unused ports
|
||||
*/
|
||||
int32 nulldev(int32 flag, int32 data)
|
||||
{
|
||||
if (flag == 0)
|
||||
return (0377);
|
||||
return 0;
|
||||
}
|
||||
97
Intel-Systems/scelbi/scelbi_sys.c
Normal file
97
Intel-Systems/scelbi/scelbi_sys.c
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
/* scelbi_sys.c: Intel 8008 CPU system interface for the SCELBI computer.
|
||||
|
||||
Copyright (c) 2017, Hans-Ake Lund
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Hans-Ake Lund shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from Hans-Ake Lund.
|
||||
|
||||
04-Sep-17 HAL Working version of CPU simulator for SCELBI computer
|
||||
12-Sep-17 HAL Modules restructured in "Intel-Systems" directory
|
||||
|
||||
*/
|
||||
|
||||
#include "system_defs.h"
|
||||
|
||||
extern DEVICE cpu_dev;
|
||||
extern UNIT cpu_unit;
|
||||
extern REG cpu_reg[];
|
||||
extern DEVICE tty_dev;
|
||||
extern DEVICE ptr_dev;
|
||||
extern unsigned char Mem[];
|
||||
extern int32 saved_PCreg;
|
||||
|
||||
/* SCP data structures
|
||||
|
||||
sim_name simulator name string
|
||||
sim_PC pointer to saved PC register descriptor
|
||||
sim_emax number of words needed for examine
|
||||
sim_devices array of pointers to simulated devices
|
||||
sim_stop_messages array of pointers to stop messages
|
||||
sim_load binary loader
|
||||
*/
|
||||
|
||||
char sim_name[] = "SCELBI";
|
||||
|
||||
REG *sim_PC = &cpu_reg[0];
|
||||
|
||||
int32 sim_emax = 4;
|
||||
|
||||
DEVICE *sim_devices[] = {
|
||||
&cpu_dev,
|
||||
&tty_dev,
|
||||
&ptr_dev,
|
||||
NULL
|
||||
};
|
||||
|
||||
const char *sim_stop_messages[] = {
|
||||
"Unknown error",
|
||||
"Unknown I/O Instruction",
|
||||
"HALT instruction",
|
||||
"Breakpoint",
|
||||
"Invalid Opcode"
|
||||
};
|
||||
|
||||
/* This is the binary loader. The input file is considered to be
|
||||
a string of literal bytes with no format special format. The
|
||||
load starts at the current value of the PC.
|
||||
*/
|
||||
t_stat sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
|
||||
{
|
||||
int32 i, addr = 0, cnt = 0;
|
||||
|
||||
if (*cptr != 0)
|
||||
return SCPE_ARG;
|
||||
if (flag != 0) {
|
||||
sim_printf ("DUMP command not supported.\n");
|
||||
return SCPE_ARG;
|
||||
}
|
||||
addr = saved_PCreg;
|
||||
while ((i = getc (fileref)) != EOF) {
|
||||
if (addr >= MAXMEMSIZE)
|
||||
return (SCPE_NXM);
|
||||
Mem[addr] = i;
|
||||
addr++;
|
||||
cnt++;
|
||||
} /* end while */
|
||||
sim_printf ("%d Bytes loaded.\n", cnt);
|
||||
return (SCPE_OK);
|
||||
}
|
||||
50
Intel-Systems/scelbi/system_defs.h
Normal file
50
Intel-Systems/scelbi/system_defs.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* system_defs.h: Definitions for the SCELBI computer.
|
||||
|
||||
Copyright (c) 2017, Hans-Ake Lund
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Hans-Ake Lund shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from Hans-Ake Lund.
|
||||
|
||||
04-Sep-17 HAL Working version of SCELBI simulator
|
||||
12-Sep-17 HAL Modules restructured in "Intel-Systems" directory
|
||||
|
||||
*/
|
||||
|
||||
#include "sim_defs.h" /* simulator defines */
|
||||
|
||||
/* Memory */
|
||||
|
||||
#define MAXMEMSIZE 16384 /* max memory size */
|
||||
#define MEMSIZE (cpu_unit.capac) /* actual memory size */
|
||||
#define ADDRMASK (MAXMEMSIZE - 1) /* address mask */
|
||||
#define MEM_ADDR_OK(x) (((uint32) (x)) < MEMSIZE)
|
||||
|
||||
/* Simulator stop codes */
|
||||
|
||||
#define STOP_RSRV 1 /* must be 1 */
|
||||
#define STOP_HALT 2 /* HALT */
|
||||
#define STOP_IBKPT 3 /* breakpoint */
|
||||
#define STOP_OPCODE 4
|
||||
|
||||
/* I/O device entries */
|
||||
struct idev {
|
||||
int32 (*routine)(int32, int32);
|
||||
};
|
||||
Reference in New Issue
Block a user