EPROM code for the Z80 Computer

The code here shows some useful routines to put in the EPROM. The first instruction allows the user to skip to a part of the EPROM that has good code. This technique allows the programmer to enter new code in a higher memory location if a mistake is made (easy to do if you are entering data into the EPROM bit-by-bit). You can simple write zeros over the JP instruction and enter another one that points to the good code, without erasing the EPROM. The target of this initial jump is a routine that allows the user to identify an entry point by placing the address on the input port switches. The simple port reflector and counter programs are for testing the basic integrity of the system. The program loader allows the user to experiment with any small program by entering it into RAM bit-by-bit using the input ports.

Line no.LocationContentsLabelInstructionComment
00010000 ;ROM programs for Montrose Student Z80 computer
00020000 ;Version 4 2/17/03
0003 0000 .ORG 0000H
0004 0000 C3 20 00 JP 0020H ;Jump to start of programs
0005 0020 .ORG 0020H
0006 0020 DB 00 IN A,(0) ;Jump to address on input ports
0007 0022 6F LD L,A
0008 0023 DB 01 IN A,(1)
0009 0025 67 LD H,A
0010 0026 E9 JP (HL)
0011 0027 DB 00 LOOP1 IN A,(0) ;Simple port reflector
0012 0029 D3 00 OUT (0),A
0013 002B DB 01 IN A,(1)
0014 002D D3 01 OUT (1),A
0015 002F C3 27 00 JP LOOP1
0016 0032 3E 00 LD A,00H ;Simple counter
0017 0034 D3 00 LOOP2 OUT (0),A
0018 0036 3C INC A
0019 0037 C3 34 00 JP LOOP2
0020 003A 2E 00 LD L,0 ;Count to 1,000,000
0021 003C 26 00 LD H,0
0022 003E 3E 10 LOOP4 LD A,16
0023 0040 3D LOOP3 DEC A
0024 0041 C2 40 00 JP NZ,LOOP3
0025 0044 23 INC HL
0026 0045 7D LD A,L
0027 0046 D3 00 OUT (0),A
0028 0048 7C LD A,H
0029 0049 D3 01 OUT (1),A
0030 004B C3 3E 00 JP LOOP4
0031 004E 21 00 08 LD HL,0800H ;Load program in RAM from input port 0
0032 0051 DB 01 LOOP5 IN A,(1) ;Look at input port 1, bits 0 and 7
0033 0053 E6 81 AND 81H ;Loop until a switch is closed
0034 0055 CA 51 00 JP Z,LOOP5
0035 0058 06 80 LD B,80H
0036 005A 10 FE DEBNC1 DJNZ DEBNC1 ;Debounce loop for switch closure
0037 005C E6 80 AND 80H ;Look at input port 1, bit 7 switch
0038 005E C2 00 08 JP NZ,0800H ;If switch is closed, jump to start of RAM
0039 0061 DB 00 IN A,(0) ;Switch open, get byte from input port 0
0040 0063 D3 00 OUT (0),A ;Display byte on output port 0
0041 0065 77 LD (HL),A ;Store byte in RAM
0042 0066 23 INC HL ;Point to next location in RAM
0043 0067 3E FF LD A,0FFH ;Turn all output port 1 lights on
0044 0069 D3 01 OUT (1),A
0045 006B DB 01 LOOP6 IN A,(1) ;Look at input port 1, bit 0 switch
0046 006D E6 01 AND 01H
0047 006F C2 6B 00 JP NZ,LOOP6 ;Loop until switch for bit 0 opens
0048 0072 06 80 LD B,80H
0049 0074 10 FE DEBNC2 DJNZ DEBNC2 ;Debounce loop for switch opening
0050 0076 3E 00 LD A,0
0051 0078 D3 01 OUT (1),A ;Turn off port 1 lights
0052 007A C3 51 00 JP LOOP5 ;Start over
0053 007D .END
Return to main Z-80 computer page.

© Donn Stewart 2004