Semi-Decent 8008 Emulator


This emulator was designed specifically to work with the Semi-Decent 8008 Assembler that I wrote and is extremely picky as to the input file format. It simply will not work with just any assembler. It does not use SYM files; it examines the actual output listing from the Semi-Decent 8008 assembler. I used this to "ROMify" SCELBAL and also will use it to develop the integrated monitor code. As peculiar as it is, it does work and is quite useful. In my opinion, it is also extremely educational. It has a conglomeration of the best features I've seen in other emulators, and then also has a few of my own. I would have permitted hexidecimal but hex wasn't really used until later in the 8008 era, so that wouldn't have been "historically accurate". The 8008 and 8080 were best understood and assembled by hand (done more often than you think, beleive it or not) in octal.

Also, note that the 8008 mnemonics supported by the assembler and emulator/debugger are the original 8008 mnemonics, not the later 8080-like set.

I am not a True Software Development Wizard anymore, but I have a reputation of being able to find problems and to fix them. My attitude is, "if you have a good debugger, and you can't find the problem, then you should look for another line of work". After I used this for debugging the SCELBAL source and making it work, I have found it to be a fairly decent 8008 emulator, which is very nice to have if you don't actually have an 8008 computer available.

The SCELBAL listing included is derived from a copyrighted work from 1976. The book originally cost $50.00 and had a somewhat nebulous copyright on the code in the book. I have tried to find out what happened to the author(s) and the company; I beleive that one of them may have died. In any event, please read the licence agreement below.

Obviously, this is something I wrote primarily for myself, and its quality should not be taken as indicative of something I'd write for a "commercial quality" audience. This is why the source code will not be available!

Features: (Version 0.5)

Breakpoints
Single-Stepping
Source-Level Debugging
Modifiable Registers, Program Counter, Flags, I/O Ports, memory
Virual Console/UART on I/O Ports 000,001 (input) and 010 (output) w selectable 7 or 8 bit ASCII (for SCELBAL)
Console can load or save text files (useful for loading/saving SCELBAL programs)
RAM Windows for viewing ranges of addresses
16 K address space
Full flag, register, and stack display
Warning on stack blow-up or blow-out (wraparound, from the top or bottom)
Warning on address wrap or access to "wrapped" addresses
Approximate 8008-1 speed on a 500 Mhz Pentium-class computer
Genuine Blinking Address Lights
Can be used to emulate an 8008 computer running SCELBAL
Command-Line mode for automatic program execution
Serial Port Support so Programs can Run on a Remote Terminal
Other Stuff, But I Forgot What



Features (Version 1.0, if any)

Definable RAM/ROM spaces with error on write to ROM
Watches on memory locations + registers+flags
More Blinking Lights (maybe)
Faster Operation w/speed control


Bad Points:

Does not load quickly AND YOU MUST RELOAD THE SOURCE IN CASE OF AN ERROR!!!
(I may fix this)
Only works properly with the "stock" OPCODES file used to create assembler listing (read that manual for more information)
Not very robust (this will depend on the time I put into it, I wrote a lot of code in a short period of time)
No true interrupt other than RESET


Requirements:

1. Windows 95+ with a reasonable amount of RAM

2. 450 Mhz or better Celeron+ processor (the faster, the better).

3. Decent video board operating at 1024*768 or better

How To Use

Primarily, it is expected that you will use the emulator/debugger to work with Scelbal or software that you wrote with the assembler.

First, load the listing file from your (
SUCCESSFULLY ASSEMBLED WITH NO WARNINGS OR ERRORS) program. Remember, you load the .LST file.

You may press RESET or highlight a line OF CODE and press the "JMP TO" button. It is expected that you will have code at location 000 000. You will not be able to set the program counter to a point in RAM or not defined as assembled output.


NOTE:


I haven't run this on a real 8008 machine yet. The 8008 doesn't have a real "reset" (except in the chip itself, where all registers goto 0). My "Reset" circuit forces an interrupt to location 0, executing a stack push-down. You need to get out of this. The code here doesn't really reflect my machines. I handle this situation with:

JUMP FAKEJUMP

JMP REALCODE

FAKEJUMP: RET


Controls:

RUN

The 8008 will run at full speed, which on a decent machine will approximate the speed of a real 8008.

STOP

The 8008 will stop.

STEP

You can step through code.

Run To RTN

Code will run until a RTN; allows you to examine registers after a subroutine runs.


Breakpoints

During a run or animation, breakpoints will stop execution, but hopefully you knew that. Click on a row in the first column of source to set a breakpoint. An asterisk will be shown. Click again to remove it. All breakpoints can be removed with the "Remove all breakpoints" menu item.


Registers

You can modify the registers by putting new values in them when the computer is stopped. You must use a proper value for the decimal/octal display setting. Upon a new RUN or STEP or ANIMATE, these registers are updated in the emulated computer.

Flags

You may change the value of a flag by double-clicking or entering a T/F or 1/0 when the computer is stopped.

Console

The console is a semi-"smart" TTY. It is addressed at INP001 and OUT010 (which just so happens to match the design of my 8008 computer). Handshaking for the imaginary UART in input is located in INP000. Bit 0 is the "data available" bit, a 1 meaning data is available. Bit 1 is the "output buffer empty" bit, 1 signifying full (do not send more characters). Bit 1, altough defined, is always 0 because the console is always "fast enough" to take in characters from the imaginary 8008 and UART. Note that you cannot modify these ports by typing into them directly - you must use the console.

Console input and output CR's are turned into CRLF's.

SCELBAL and this console deal with two "control" type characters with no clear modern meaning. CTRL-T tells the virtual console to line feed times. It may have form fed paper, or cleared a CRT to the top of the screen and put the cursor to <0,0>.

The RUBOUT character (ASCII 127) was historically important to paper tape/teletypewriter type machines.. If you made a mistake, the RUBOUT punched all holes and could then be ignored. It also had some use fo security, such as in passwords being "rubbed out". A backspace sends a RUBOUT to SCELBAL, and when this is echoed as a backslash, this represents one character removed.

Note that bit 7 is stripped off of output from the program and added to input characters by default. This is because SCELBAL expects this, which effectively makes the UART N,7,2 instead of N,8,1. By unchecking the "Bit 8 Set" checkbox, you can use conventional full 8-bit ASCII.

SCELBAL expects upper case only. The checkbox for UPPER CASE is on by default.

You may load or save files to and from the console via the menu. First, you set their valid file names from the menu. Then, to load, select the "load into console" from the menu. It will remain checked until fully loaded or until it is unselected (which resets the file pointer to the beginning). Note that code must be running to reset bit 0 on the UART by the code reading the console input on each character in order for this to function properly. This can be used to load SCELBAL programs into SCELBAL once the program is running. The checkmark disappears from the menu when the load is finished.

To save output, use the "Save from console" checkbox. It will not function unless a valid output file has been defined first with the output file menu item dialog box. Selecting it again closes the log. This can be used to save SCELBAL programs from SCELBAL "LIST" commands.

SCELBAL expects upper case only. The checkbox for UPPER CASE is on by default. Note that with a CHR$(XXX) command, you can send lower case characters, as well as in quoted text, although I suspect that most printers and most VDT's of the era supported only upper case.

Note that when you are running on an extremely slow computer or when you are attempting to use SCELBAL in animation mode as opposed to RUN mode (not recommended unless you have a really, really fast computer), typed input characters can be lost. This is to be expected. What happens is, you enter a character and enter another one before SCELBAL has grabbed the first character and reset the input flag. This mimics what would happen with most UARTs and their surrounding circuitry and handshaking. Some serial converters had additional circuitry that would refuse character 1 until character 0 had reset the input buffer. Of course, modern PC's have built in keystroke buffers, and Windows itself buffers quite a few characters before the message buffer is full, but we aren't using those features here!


RAM Windows

You may open up to three RAM windows on various ranges of RAM/ROM, in decimal or octal. They are updated with each step or animation. For this reason, animation will be slower depending on how many you open, whether or not HL tracking (see below) is on each window, and the speed of your machine.

Double-click on a RAM window row and you can change a particular location in RAM, in decimal or octal. with the Modification window. Modifying RAM will temporarily stop the 8008. The RAM modification window also allows scrolling back and forth, 8 or 10 bytes at a time depending on the decimal/octal mode. If you need to go farther to the next RAM location to modify, close the window, select a new location via the RAM window, double-click, and the modification window will allow modifications to that new location.

The RAM Window can be "forced" to update by scrolling it or by pressing the "Force Refresh" button while the 8008 is RUNNING.

The text display (of traditional design, where "." represents an unprintable character) is aware of 7 or 8 bit ASCII and adjusts itself to show you the characters accordingly, depending on how you have the virtual TTY set.

"Track H+L Registers" will highlight and track the row where the H+L registers "point to" as the screen is updated.

HL Breakpoint

It is possible to set an HL breakpoint via a dialog box displayed by main menu selection. When the breakpoint is set from the main window, when the registers point to a location, the execution will stop in animated or run modes. The HL register backgrounds turn RED to display this type of breakpoint. Note that this is not the same as a regular code execution breakpoint. This can be useful for finding how memory gets clobbered. The HL breakpoint can be set in octal or decimal. It is an especially good example of why it is easier to "think" with the 8008 in octal.


Warning Messages (can be toggled on or off)

Note that none of the follwing will actually stop a real or this emulated 8008 from operating; nonetheless, they are usually indicative of program errors.

For example, if you blow the stack out (meaning, you go down too many levels), it wraps to the first location in the stack. Unless you are writing extremely strange code, this is generally unexpected. Likewise, a stack blow-up, where you return past location 0, is also legal, but odd.

Addressing past 16K is also legal, but generally not done deliberately. The 8008 simply points to X mod 16K.


Example use with version of SCELBAL provided:

1. Run the emulator.

2. Load SCELBAL .LST file.

3. Reset 8008.

4. Run.

5. Interact with the virtual CRT.

6. Learn SCELBAL (like BASIC) and save and load programs to local disk.

A few notes on SCELBAL (I will expound on this later)

1. Use the SCR command FIRST.

2. Use BASIC-like syntax.

3. You MUST (MUST) define variables (a-z, and only about 20 of them) BEFORE using them. LET is optional.

4. There is an immediate mode.

5. If something funny happens in math, use parentheses.

6. Exponentiation (^) is available.

7. Functions: INT, SGN,ABS, SQR, RND, CHR, TAB.

8. No SAVE and LOAD yet from within SCELBAL.

9.CONTROL-C only works on an input statement.


Use With An External Computer Terminal

I had considered using a Telnet server within this program; I thought that that was too modern; but I did decide to support connecting a terminal to the back of a PC for that "old-time feeling". Checking the "Serial Console.." menu item brings up a small box for you to select COM port and speed. I thought that over 1200 baud would be silly. The "Bit 8 Set" affects the serial port I/O also. You can (with appropriate current loop to RS-232 conversion equipment) hook up an ASR-33 to the back of the PC and work with SCELBAL at 110 baud!


(need to set parity, stop bits, etc)


Note that the virtual UART does not provide Data overrun, parity, etc errors, and SCELBAL (to be more exact, the I/O routine) has no code to check for this anyway. The interrupt routine in the PC and the VB messages do, however, so the bottom line is, the terminal settings must match these settings in order for this to work.

No handshaking whatsoever is supported. Characters are NOT buffered, what you'd expect from SCELBAL.

It would be very geeky indeed to loop back one serial port to another on the emulator PC, and run a terminal emulator in addition to the 8008 emulator.

Command Line Usage

It is possible to have the program automatically load a .LST file and run from the startup group. The format is:

8008emu filename.lst S 1200 N 8 1

Where filename is the fully qualified name of the file (with path if not in the default directory)

S signals use of the external Serial "TTY" console

BAUD = 110,300,1200

Parity E, O, M, S = Even, Odd, Marking, Spacing

Bits=7 or 8

Stop bits= 1 or 2

This might be useful for making a "hidden" virtual 8008 computer for a museum, for example. Computers capable of running this program even at 8008-1 speeds will be junk in a few years.


No-BS License Agreement

Demonstration code from a third party is provided that may or may not have an expired copyright. The licencee must be aware that a fee might have to be paid to that party if it is ever determined that the copyright is still in effect. The licensee agrees to destroy all copies of this code if they choose not to pay a fee or if the code is not made available. This code is not separable from this license.

The licencee agrees that the author's liability is limited to the cost of this software (nothing) .

The licencee agrees that the author has no liability to provide updates, improvements, bug fixes, or support for this software, although it has been tested in controlled environments and has been found to be largely functional and free of errors; it has been provided in good faith as a useful educational tool.

The licencee aggrees that the software provided has not been rigorously produced or tested to the highest commercial standards, and therefore must not be used in the production of mission-critical software or firmware, such as, but not limited to, that found in military systems and equipment, power plants, industrial processes, nuclear systems, transportation systems, medical equipment and medical systems, and so on.*

The licencee will not permit either actively or passively, nor aid in, the dissemination of this code via mechanical or electronic means to other parties other than as from this web page; examples being, but not limited to, those such as the posting of the code to the Internet or making the code available on a server on an intranet or the Internet. I have limited bandwidth available on this site; please do not link to this page.

No party other than the copyright holder has the authority to modify this agreement. If any part is found to be legally invalid, this does not invalidate other parts of the agreement.

Upon your agreement with these terms, you may download the code here.


* Like, any responsible, sane person would actually do this - SL.


I welcome your comments. Please email me at