Have you ever wished that you could peel back the cover on your 1802 and see what was really going on inside of it? Wouldn't it be nice to be able to peek underneath, examine what was in each register and watch as each instruction was executed? Anybody who has ever written a program has known the frustration of watching his computer go off into never-never land and hang, giving no clue as to where it has gone or why. While this article cannot prevent this, it will present a way to "look inside" and see what happened.
This article is about a dynamic debugging technique that goes by the name of "WINDOW". " WINDOW is a program designed to simulate what would happen if you could put a glass lid on an 1802 and watch the fun inside. It would be easy to dismiss WINDOW as another single step type trace program, but that would be unfair. A close examination of its operation will reveal functions that were previously only available on expensive microprocessor development systems. In fact, once you have used it for a while, I suspect that you will wonder how you ever debugged machine code without it. In addition, those who are not confident of their knowledge of how the entire 1802 instruction set works may find it a valuable learning tool.
"BUT WHAT DOES IT DO?" you ask. Glad you asked that. What the program does is pretend that it is an 1802, maintaining a set of 1802 like registers while fetching 1802 instructions from your system's memory and executing them. AND. .. while it does all that it maintains a complete display on your screen of everything that is happening! Which means that you can follow what is going on, just as if you had pried the cover off and peeked inside. If you tell WINDOW to execute a piece of code that is in fact a program you wish to test, you can see what your 1802 would do if it was to execute that code instead. Handy, eh?
WINDOW's basic function is to emulate the execution of 1802 machine code. What you see on the screen at any given moment is the state of the emulated 1802, including the contents of its internal registers and the instructions it is about to execute. The display is divided into fields that are updated as required. Data displayed in these fields includes:
The program allows you to modify the contents of any of the displayed registers, any memory location or even which register is the PC or X register.
Other features include automatic detection of warm versus cold starts, the ability to exit to a monitor and return at any time, three different modes of emulating programs and a novel way of avoiding interference with emulated programs that also use the VDU screen. WINDOW is even smart enough to avoid being overwritten by programs that it is emulating.
WINDOW software is designed to work with the ACE VDU board using the MC6847 video chip. Other memory mapped 32 x 16 video systems could probably be made to work, especially if they supported inverse video as bit 8 of each data word. See the section on program customization for details on implementing other hardware configurations.
Input to the system is designed to be from an N line port, with an EF line to indicate that data is ready. The port should probably be hooked to an ASCII keyboard, although other types can be used. In fact, the hex keypad on most versions of the ELF could probably be pressed into service if necessary.
The WINDOW program is a 2K program, completely page relocatable anywhere in RAM without modification. It can be modified to run in PROM, although I'm not sure why anyone would want to do that. In fact, it is possible to exit from it to your monitor, use the monitor to move it somewhere else and then continue there exactly where you left off.
Memory requirements for the program are which ever 2K block you load it into and the 1K 2114 on the ACE VDU board located at E000. The 1K memory on the VDU board is used to store the WINDOW screen display in the low two pages and the emulated program display in the high two pages. As only the first two pages are seen on the screen, the SWAP command interchanges the top and bottom two pages so that both displays can be viewed.
Perhaps the best way to learn about WINDOW is to study the diagram of its screen format and then study its command set. Except where noted all commands are available at any time. Commands are immediately executed when the single character that represents them is typed in. This means that you do not need a carriage return after each command, a feature you will soon see the time saving value of. Commands that require parameters such as addresses or data will prompt you for them, and your answer is then entered in the scratch line and terminated by typing a carriage return. ANYTHING entered into one. Note that the use of backspace (08) will allow you to edit an answer to a prompt, and a carriage return with no data in the scratch line will terminate the current command without executing it.
To get WINDOW up and running you first have to type in the machine code, or get a copy of it somewhere. Then refer to the section in this article on INTERESTING MEMORY LOCATIONS to customize the code to the requirements of your system. (If your system does not have the hardware required see the section on PROGRAM MODIFICATION). Save the code on tape or disk or whatever you have and you are ready to go. The code can be loaded without further modification on any page boundary where there is a 2K continuous block of memory.
WINDOW is cold started and warm started at the same address - the first byte of the program. It decides whether it has already been initialized (cold start) or whether this is a restart (warm start). As long as you always exit to your monitor from WINDOW with the EXIT command this works quite well. In this way, it is possible to get in and out of the program in an orderly manner without having to reset the whole system every time. This can be handy if you decide to load something into memory with your monitor mid-way through the emulation of another program. (Actually, I implemented this feature because I am too lazy to remember a separate warm and cold start address, so all my programs start at the address of their first byte.) The only problem with this system is that if you wish to restart from scratch you must reload the code into memory, but you should never need to do this.
Once the program starts up, setup commands can be used to configure the pseudo 1802 to how you require it (useful for testing parts of a program) and execute commands can be used to select the mode of emulation. Applications include not only debugging your awn code, but bringing up other peoples' code that just doesn't seem to work quite right on your system. You can actually find out for sure what is being passed in and out of that funny program you typed in from a hex dump in an old IPSO FACTO. WINDOW is easy to use and so far I have not succeeded in making it crash.
One final word about using the code. If WINDOW encounters something it doesn't like, it will flash an error code in the error field. Hitting any key will allow you to continue what ever you were doing, but it would be a good idea to look up the error code and figure out what happened. Otherwise, you will never know if what WINDOW is doing with the code is what your 1802 would be doing after encountering that condition.
WINDOW can be run from EPROM if you can provide a fixed RAM page for its use. The code should then be modified as follows:
| Address | Data |
yy0D | F8 xx |
zzF6 | F8 xx B9 F8 29 A9 59 C0 yy 00 |
- where xx is the RAM page high byte, yy is the start address of the EPROM and zz is the yy + 04. Cold start execution would be at zzF6 and warm start at yyOO.
WINDOW is a fairly complicated program. For example, it employs three different subroutine calling techniques and still remains completely page relocatable. There is not a whole lot of spare memory in the 2K space to play with. Customizing the program to fit your system may be difficult, and will require a full commented assembly language listing to do it. Therefore here is what I would recommend.
Assembly language listings of the standard WINDOW program are available for $5 from me [Note: this article was published back in 1982; presumably the author's offer does not still stand, and cosmacelf.com does not have this assembly language listing or contact information for Mr. Hill.] This will barely cover the cost of photocopying the listing and mailing it to you. I'm not trying to sell software as such, but I can't afford to distribute free listings and I don't feel I should take up most of an IPSO FACTO issue to provide a service to those few whose interests extend beyond a hex dump. If you think the program will require modification to run on your system, describe what you want to do and I will include some comments with your listing as to how you should try to modify it. NOTE that I am not offering to rewrite the code for all 500 or so club members, but will try to point the way for anybody that needs help.
| Key | Name | Action |
| P | PC SET |
|
| X | X SET |
|
| D | D SET |
|
| F | DF TOGGLE |
|
| M | MEMORY DISPLAY |
|
| B | BREAK POINT |
|
| E | EXIT |
|
| W | WRITE |
|
| R | REGISTER |
|
| N | NEW LINE |
|
| S | SWAP SCREEN |
|
| <cr> | STEP |
|
| T | TRACE |
|
| Q | QUICK |
|
| Address | Data | Comment |
01A0 |
3E |
A "BN3" instruction where the branch takes place if there has not been a key pressed. Modify to reflect the status flag from your keyboard. |
01A6 |
69 |
an "INP1" instruction that reads the port hooked to the keyboard. |
0236 - 0243 |
<cr>, R, D, F, P, X, T, M, S, B, E, Q, W, N | The table of ASCII characters that correspond to the single character commands. These values can be changed to any value that you enter from your keyboard, i.e. EBCDIC characters. |
02B2 |
10 |
A constant that determines how fast TRACE mode executes. Modify to suit your tastes. |
0196 |
18 |
A constant that determines how fast the cursor flashes. Modify to suit your tastes. |
00AA |
08 |
The value of your keyboard's backspace key. |
00AE |
05 |
The difference between your keyboard's backspace key value and the carriage return value. |
02DA - 02DB |
8000 |
Address of your monitor. |
| Code | Meaning |
| 1 | Illegal instruction found (68). Not executed. |
| 2 | Write error. A value was stored in memory but cannot be read back. Can be caused by attempting to store in non-existent memory, EPROMS or write only devices. |
| 3 | Attempt to write into memory where the WINDOW program is. Value not stored. |
| 4 | RAM versions: same as an error # 3. EPROM versions: attempt to overwrite the RAM page. Value not stored. |
0000 F8 06 A3 90 B3 D3 93 B4 B5 FC 05 B7 B8 FF 04 B2 0010 B9 F8 6D A4 F8 82 A5 F8 01 A7 F8 12 A8 F8 7F A2 0020 E2 F8 29 A9 09 3A 2E F8 E0 BB D4 02 09 00 EB F8 0030 E3 BB F8 FF AB 93 FC 01 BC BD F8 E2 AC F8 00 AD 0040 F8 04 AE 4D FE 3B 56 FE BE F8 20 C7 F8 A0 73 2E 0050 8E 32 40 9E 30 44 FE BE 4C 3A 4E 1B E2 F8 00 73 0060 82 3A 5D 52 F8 2C A9 F8 01 59 30 1D D3 E2 BF 96 0070 73 86 73 93 B6 83 A6 94 52 46 F4 B3 46 A3 9F 30 0080 6C D3 E2 BF 96 B3 86 A3 12 72 A6 F0 B6 9F 30 81 0090 F8 E1 BB F8 C1 AB 93 BE 46 AE 0E FE 4E F9 80 5B 00A0 1B 3B 9A F8 31 A9 D4 01 95 FF 08 32 C3 FF 05 32 00B0 CF FF 2D C7 FF 07 FC 0A FA 0F 59 19 D7 58 89 FF 00C0 36 3A A6 89 FF 31 32 A6 F8 A0 5B 29 2B 30 A6 D4 00D0 01 A8 AE 29 D4 01 A8 BE F8 A0 5B 2B 8B FF C0 3A 00E0 D8 F8 E0 BB 89 FF 2E 3A EE 12 42 A6 02 B6 D5 09 00F0 0E 10 AD 05 06 AD 12 A3 01 3F AD 04 BD 02 BD 00 0100 BF CA BC AA AA AA AA AA BF CA BC AA FF FF FF FC 0110 BF CA BC AA AA AA AA AA BF CA BC AA FF FF FF FF 0120 BF CA BC AA FF FF FF FF BF CA BC AA FF FF FF FF 0130 BF CA BC AA FF FF FF FF BF CA 80 AA AA AA AA AA 0140 BF CA AA AA FF FF FF FF BF CA AA AA FF FF FF FF 0150 BF CA C0 B2 FF FF FF FF BF CA AA AA FF FF FF FF 0160 BF CA C2 F2 FF FF FF FF BF CA AA AA FF FF FF FF 0170 BF CA C2 F2 FF FF FF FF 3F CA AA AA FF FF FF FF 0180 00 D7 1D D7 32 0A FA 0F AC 0A F6 F6 F6 F6 BC D5 0190 F8 B7 AB 9F 5B F8 18 BE 0B FB 80 5B 2E 9E 32 95 01A0 3E 9C 0B F9 80 5B 69 D5 E9 29 29 49 FE FE FE FE 01B0 F1 D5 F8 00 AB AD F8 E2 BD 0B 52 0D 5B 02 5D 1B 01C0 1D 9B FF E2 3A B9 F8 E0 BB D5 D7 1D D7 32 0A 32 01D0 E1 F8 2A A9 E9 9A F7 3A DD 19 8A F7 CE 3E E1 F8 01E0 00 D5 06 37 05 36 3E 04 35 03 34 02 33 01 32 39 01F0 31 38 14 15 0F 37 36 35 12 12 05 11 34 33 05 09 0200 14 32 31 06 04 04 08 30 00 D4 01 B2 D4 02 48 D4 0210 02 14 30 0F 3E 14 69 93 BE F8 36 AE 4E 32 14 F3 0220 3A 1C 8E FF 37 D4 07 F8 45 67 7E 86 98 A4 AF DC 0230 BF C9 D6 E9 F3 48 0D 52 44 46 50 58 54 4D 53 42 0240 45 51 57 4E 00 D4 02 4F D4 01 81 D4 06 31 D5 D4 0250 01 81 0A 32 66 D7 AC 2A 9C FA 07 FB 07 32 63 D4 0260 03 00 D5 D4 04 00 D5 D4 00 90 F6 8E FA 0F FE AF 0270 1F D4 00 90 F8 8E AA 9E BA 8F A9 D7 BA D5 D4 00 0280 90 FB 8E D7 3F D5 F8 21 A9 F8 37 AB 09 FB 01 59 0290 F6 F8 B0 C7 FC 01 5B D5 D4 00 90 F6 8E FA 0F AC 02A0 D7 8B 30 48 D4 00 90 F6 8E FA 0F AC D7 98 D5 D4 02B0 02 45 F8 10 BE 2E 9E 3A B5 D4 01 CA 3A AF D5 D4 02C0 01 B2 3E C2 69 D4 01 B2 D5 D4 00 90 F8 F8 2B A9 02D0 8E 59 29 9E 59 D5 D4 01 B2 C0 80 00 D4 00 90 F8 02E0 F8 26 D4 02 CF D4 06 0E D5 D4 02 4F D4 01 CA 3A 02F0 E9 30 48 D4 00 90 FD F8 25 D7 26 8E D7 D6 D5 00 0300 9C D4 07 F8 18 21 27 85 18 2D 33 00 63 68 6E 74 0310 97 7F 82 D7 AC D7 AC D5 D7 2F 0A D7 3F 9C 3A 21 0320 D5 8C FE A9 D7 AE D5 8C FE A9 D7 B5 D5 D7 2F 09 0330 D7 D6 D5 8C 32 59 FF 08 32 5D 3B 49 D4 00 90 EF 0340 8E D7 3F D7 1A D7 32 30 2F FC 10 FE A9 D7 63 D7 0350 1A D7 32 0A D7 49 F8 E0 BB D7 1A 30 24 F8 B1 D4 0360 01 90 D5 D7 24 8A 30 6B D7 24 9A D7 3F D5 D7 24 0370 09 AA 30 78 D7 24 09 BA 8C FE A9 19 D7 BA D5 D7 0380 8B D5 D7 98 D5 8C FA 04 32 94 D4 00 90 F3 8E FA 0390 01 AE 30 BC F8 00 C8 F8 02 AE 8C FA 04 32 A2 F8 03A0 04 AE E9 F8 21 A9 8C FA 03 32 D2 F6 3B DB 32 B3 03B0 F8 01 C8 F8 02 F2 32 BC 8E FB 01 AE 1A 9A BD 8A 03C0 AD 93 BE 8C FA 08 32 CC 8E FB 01 38 8E FC ED AE 03D0 0E A3 0A FF CC 3A B8 F8 04 30 B5 F8 20 A9 09 32 03E0 B8 30 BC 4D BA 0D AA D7 1D 19 D7 BA D5 15 E5 13 03F0 E3 13 17 00 00 00 00 00 00 00 00 00 00 00 00 00 0400 0A FE 3B 4A F8 28 AD 99 BD F8 D3 5D 2D 0A 5D FE 0410 FF FC 32 21 4A FA F7 5D 8C FA 08 3A 21 D7 1A D7 0420 32 F8 21 A9 09 F6 52 29 09 EA DD E2 59 F8 37 AB 0430 19 F0 7E 59 F6 F8 B0 C7 FC 01 5B 29 09 D7 3F 8C 0440 FF 08 3B 49 FF 06 CE D7 AC D5 FA 08 3A 04 8C F6 0450 FA 04 52 8C FA 03 F4 D4 07 F8 62 62 93 9C A8 B3 0460 D9 D9 F8 77 AB F8 21 A9 8C F6 09 33 74 F9 04 59 0470 F8 B1 30 79 FA FB 59 F8 B0 5B D7 1A D7 32 0A F6 0480 F6 F6 F6 73 0A FA 0F AC D7 8B D4 03 59 60 F0 AC 0490 D7 98 D5 D7 1A 89 F6 AC D4 03 18 D5 D7 1A D7 32 04A0 09 D7 D6 D7 1A D7 B5 D5 D7 1A D7 32 F8 24 A9 09 04B0 D7 D6 D5 F8 72 AB F8 04 A9 D7 32 F8 22 A9 49 52 04C0 49 FE FE FE FE F1 59 D7 49 09 D7 D6 D7 1D 89 F6 04D0 AC D7 98 F8 04 A9 D7 B5 D5 F8 21 A9 8C F6 F8 B2 04E0 AB 09 33 EB FA FD 59 F8 B0 30 F0 F9 02 59 F8 B1 04F0 5B D5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0500 D3 E2 22 BF 13 93 73 83 73 23 03 A3 97 B3 9F 30 0510 00 D3 E2 60 72 A3 72 B3 30 11 F8 23 C8 F8 22 A9 0520 09 FE A9 D8 8C FE A9 49 BA 09 AA F8 20 A9 D8 8C 0530 FE A9 D7 27 9A F6 FF 70 3A 3E 9A FC 02 BA D8 F8 0540 20 A9 9F 59 F8 32 AB 49 BF 9F 73 F6 F6 F6 F6 D7 0550 58 60 F0 FA 0F D7 58 D8 9F FF 0A CF FC 39 FC 81 0560 5B 1B D8 F8 15 C8 F8 1F C8 F8 1B 52 89 FE FE FE 0570 FE AB F8 70 7E BB 8B F4 AB D8 9F 73 D7 66 60 0B 0580 FA DF F3 C6 F8 20 5B F8 E0 BB D8 D7 1D F8 10 D7 0590 7A F8 22 A9 F8 10 30 A3 D7 1A F8 18 D7 7A F8 23 05A0 A9 F8 18 52 8C 59 FE A9 F0 D7 7A D8 D7 1D 49 BA 05B0 09 AA 1A 30 BA 49 BA 09 AA 2A 8A 59 29 9A 59 D7 05C0 69 D7 47 D7 47 F8 E0 BB D8 F8 B4 C8 F8 B3 60 C8 05D0 F8 B2 D4 01 90 D8 73 9A 52 99 F7 32 C9 93 FF 05 05E0 52 9A F7 3B ED F8 08 F4 52 9A F7 3B CC D7 34 60 05F0 F0 5A 52 0A F7 3A D0 F8 26 A9 E9 8A F7 BF 29 9A 0600 77 3B 0D 3A 0D 9F FF 10 33 0D D4 06 0E D8 D7 32 0610 F8 20 AB F8 E1 BB 9A D7 49 8A D7 49 1B 4A D7 49 0620 8B FA 0F 3A 1C 8B FC 10 AB FF A0 3A 16 F8 E0 BB 0630 D5 F8 2C A9 09 AB 9A D7 49 8A D7 49 1B 93 BE FC 0640 01 BD F8 46 AE DE F8 D5 A3 0A 32 A7 9C FC 00 AD 0650 4D AE 8B F9 0F FC 20 AB 2B F8 A0 5B 8B FA 0E 3A 0660 58 8B 59 D5 9C D3 D8 10 F0 52 F8 8C 5B 1B 8C FA 0670 04 3A 7E 8C D3 D8 40 F9 D3 9C FF 03 30 CD 8C FF 0680 04 C6 2B C4 AC FF 04 33 8A 8C D3 D8 70 52 8C 32 0690 AD FF 08 32 AA 33 9B AC F8 22 C8 F8 25 AD D3 DF 06A0 D3 FA 07 AC D3 F4 52 F8 19 C8 F8 3D C8 F8 34 AD 06B0 D3 DF 52 8C FE FE D3 DC 88 D3 FF 0C 3B CE FF 02 06C0 30 CD 8C D3 D8 C8 D3 FF 08 3B CE FF 06 C6 D3 52 06D0 D3 F9 52 8C DE 52 4E A3 F0 FE F4 52 4E F4 AD 0D 06E0 F9 80 FA BF 5B 1B 4D FE 3B DF 8B F9 03 AB 30 D5 06F0 F8 92 5B 1B 8C D7 58 30 D5 1A 0A D7 49 30 D5 00 0700 64 64 64 73 64 64 8E B3 64 64 64 64 6A 64 64 C2 0710 4C 44 CE 49 4E C3 44 45 C3 49 44 CC 4C 44 C1 53 0720 54 D2 4F 55 D4 49 4E D0 47 4C CF 47 48 C9 50 4C 0730 CF 50 48 C9 49 52 D8 53 45 D0 53 45 D8 2A 49 CC 0740 42 52 A0 42 51 A0 42 5A A0 42 44 C6 42 31 A0 42 0750 32 A0 42 33 A0 42 34 A0 53 4B D0 42 4E D1 42 4E 0760 DA 42 4E C6 42 4E B1 42 4E B2 42 4E B3 42 4E B4 0770 4E 4F D0 53 4E D1 53 4E DA 53 4E C6 53 49 C5 53 0780 51 A0 53 5A A0 53 44 C6 52 45 54 A0 44 49 53 A0 0790 4C 44 58 C1 53 54 58 C4 41 44 43 A0 53 44 42 A0 07A0 53 48 52 C3 53 4D 42 A0 53 41 56 A0 4D 41 52 CB 07B0 52 45 51 A0 53 45 51 A0 41 44 43 C9 53 44 42 C9 07C0 53 48 4C C3 53 4D 42 C9 4C 44 D8 4F 52 A0 41 4E 07D0 C4 58 4F D2 41 44 C4 53 44 A0 53 48 D2 53 4D A0 07E0 4C 44 C9 4F 52 C9 41 4E C9 58 52 C9 41 44 C9 53 07F0 44 C9 53 48 CC 53 4D C9 52 86 F4 A6 06 A6 D5 00[ Download binary: window.zip ]