Software: LCD plus Interrupts
Each of our four interrupts causes the 8085 to execute the equivalent of a CALL to a specific address associated with that interrupt. Each address is spaced out 4 bytes from the addresses for other interrupts (not listed below). This gives only enough space for a vector, that is, a jump or call to another location in memory where the actual interrupt handler is located.
The interrupt vector locations below are built into the 8085. The interrupt handler locations are just where I've decided to place the handlers for this test.
Interrupt Vector Handler TRAP 0024H 0070H RST5.5 002CH 0080H RST6.5 0034H 0090H RST7.5 003CH 00A0H
What the Handlers Do
Each interrupt will load the HL registers with the address of a NULL-terminated string to be printed on the LCD, call the LCD SOUT routine to send the string to the LCD, then re-enable interrupts and return execution to the main program loop.
As a result, each message will be printed repeatedly for so long as the interrupt key is pressed. This is useful in an initial test, since it makes it easy to see the response to the interrupt key even if our current location in the LCD data buffer is outside the area displayed by our LCD. The LCD data buffer is 40 characters long for each line of the display. I'm using a 2x16 character display, which means there are 24 character positions on each line that don't show up on the display. When the real software gets written for the system further down the road, we'll be writing it so that it accounts for the size of our display and doesn't print "off screen". For the time being, we're going to go with quick and dirty code just to make sure all the hardware is behaving as expected. We'll do nicer code later.
I've also included a version of the program that has a loop at the end of each interrupt handler that waits for the interrupt's key to be released before continuing. This can be used as a model for cleaner software later, or if you are using a 2x40 character display on your MAG-85.
The full dump of my system's memory can be downloaded here. I've included ASCII dumps and BIN files that can be used with a device programmer or used for hand-programming your own memories. LCDINTR1 is the version that will repeat the interrupt's message on the LCD so long as the interrupt key is held down, LCDINTR2 is the version that will print the message once, then wait until the key is released before re-enabling interrupts and continuing.
LCDINTR1: BIN file ASCII file
LCDINTR2: BIN file ASCII file
Code in Detail
Here is the code we've added to our LCD program. Consult the files above for the full changes, I'm just covering the interrupt vectors and handlers here.
0000 C3 00 01 RESET: JMP 0100 ;Go past intr code to main prog. ... 0024 C3 70 00 TRAP: JMP 0070 ;Go to the TRAP handler. ... 002C C3 80 00 RST55: JMP 0080 ;Go to the RST5.5 handler. ... 0034 C3 90 00 RST65: JMP 0090 ;Go to the RST6.5 handler. ... 003C C3 A0 00 RST75: JMP 00A0 ;Go to the RST7.5 handler. ... 0070 26 07 MVI H,07H ;Put address 0700 in HL. 0072 2E 00 MVI L,00H ;Loc of string "TRAP " 0074 CD 18 02 CALL SOUT ;Send the string to LCD 0077 FB EI ;Enable Interrupts 0078 C9 RET ;Return ... 0080 26 07 MVI H,07H ;Put address 0710 in HL. 0082 2E 10 MVI L,00H ;Loc of string "RST5.5 " 0084 CD 18 02 CALL SOUT ;Send the string to LCD 0087 FB EI ;Enable Interrupts 0088 C9 RET ;Return ... 0090 26 07 MVI H,07H ;Put address 0720 in HL. 0092 2E 20 MVI L,00H ;Loc of string "RST6.5 " 0094 CD 18 02 CALL SOUT ;Send the string to LCD 0097 FB EI ;Enable Interrupts 0098 C9 RET ;Return ... 00A0 26 07 MVI H,07H ;Put address 0730 in HL. 00A2 2E 30 MVI L,00H ;Loc of string "RST7.5 " 00A4 CD 18 02 CALL SOUT ;Send the string to LCD 00A7 FB EI ;Enable Interrupts 00A8 C9 RET ;Return ... String Data: 0700 54 52 41 50 20 00 ... ; "TRAP " 0710 52 53 54 35 2E 35 20 00 ... ; "RST5.5 " 0720 52 53 54 36 2E 35 20 00 ... ; "RST6.5 " 0710 52 53 54 37 2E 35 20 00 ... ; "RST7.5 "
Run the Test
Connect the keys, enter the code in the memory, and run the test. If all is well, after RESET is released on the 8085 the program will display a welcome message on the LCD and start blinking the SOD LED. Then you can press any of the four interrupt keys, which should cause the appropriate message telling you which key was pressed.
Once this is working, you are ready to add the keyboard interface hardware.