; EPROM PROGRAMMER FOR NASCOM II Z80 MICROCOMPUTER
; Guy Fernando (1982)
; The code has been recently disassmbled as shown here, but the
; instructions untouched since originally written back in 1982.
;
; Display to Screen Program Title and Version Caption
;
RST 0x28
DB 0Ch
DB "Eprom Program Package"
DB 0Dh
DB "I4CY 1982 Version 1.0"
NOP
;
; Display to Screen Read and Write Commands
;
NEW: RST 0x28
DB 0Dh
DB 0Dh
DB "Enter R to Read from eprom"
DB 0Dh
DB " W to Write to eprom"
DB 0Dh
DB 0Dh
NOP
;
; Response from Keyboard to Determine Read or Write Choice
;
OPT: RST 0x08
CP 52h ; 'R'
JP Z,RD
CP 57h ; 'W'
JP Z,WR
LD B,C
JP OPT
;
; Read From EPROM Mode Routine
;
RD: RST 0x28
DB "In Read Mode"
DB 0Dh
DB 0Dh
DB "Enter Starting Address"
DB 0Dh
NOP
CALL ALPNU
LD (TAB+0),DE
RST 0x28
DB 0Dh
DB 0Dh
DB "Enter Number of Bytes to be Read"
DB 0Dh
DB "(ie.2716=0800 & 2732=1000)"
DB 0Dh
NOP
CALL ALPNU
LD HL,0000h
LD BC,CF07h
OUT (C),B ; port B control to bit mode
LD B,40h
OUT (C),B ; B0:B5=output, B6=input
NEXTR: LD BC,0F06h
OUT (C),B ; port A control to output mode
LD C,04h ; port A data
OUT (C),L ; output L on port A
LD BC,0805h ; port B data
DEC B
EX AF,AF
OUT (C),B ; 00001000, data direction write
LD B,09h
OUT (C),B ; 00001001, enable data bus
LD B,C
LD B,0Bh
OUT (C),B ; 00001011, low address strobe
LD B,08h
OUT (C),B ; 00001000, disable data bus
LD C,04h ; port A data
OUT (C),H ; output H reg on port A
LD H,C
LD BC,0905h ; port B data
OUT (C),B ; 00001001, enable data bus
LD B,0Dh
OUT (C),B ; 00001101, high address strobe
LD B,08h
OUT (C),B ; 00001000, disable data bus
LD BC,0004h ; port A data
OUT (C),B ; output 00h on port A
LD A,0FFh
RST 0x38 ; ?
OUT (06h),A ; port A control to bit mode
OUT (06h),A ; A0:A7=input
LD BC,0005h ; port B data
OUT (C),B ; 00000000, data direction read
LD B,01h
OUT (C),B ; 00000001, enable data bus
IN A,(04h) ; read data on port A into A reg
INC B
PUSH BC
PUSH HL
PUSH AF
PUSH DE
LD A,E
OR D
JP Z,ENDP ; quit when finished
POP DE
DEC DE
LD BC,(TAB+0)
ADD HL,BC
POP AF
LD (HL),A
POP HL
POP BC
LD B,00h
OUT (C),B ; 00000000, disable data bus
INC HL
JP NEXTR ; next byte to read
;
; Table Variable Space
;
TAB: DB 00h ; First Memory Address
DB 48h
DB 00h ; Last Memory Address
DB 50h
DB 00h ; Number of Bytes
DB 08h
DB 00h ; Starting Address of EPROM
DB 00h
;
; Write to EPROM Mode Routine
;
WR: RST 0x28
DB "In Write Mode?"
DB 0Dh
DB 0Dh
DB "Enter First Memory Address"
DB 0Dh
NOP
CALL ALPNU
LD (TAB+0),DE
RST 0x28
DB 0Dh
DB 0Dh
DB "Enter Last Memory Address"
DB 0Dh
NOP
CALL ALPNU
INC DE
LD (TAB+2),DE
LD D,D
LD B,C
LD BC,(TAB+0)
LD D,B
LD B,C
LD HL,(TAB+2)
SBC HL,BC
LD (TAB+4),HL
PUSH HL
DB 0EFh
DB 0Dh
DB "Amount of bytes to be written="
NOP
POP HL
RST 0x18
LD H,(HL)
RST 0x28
LD C,B
DEC C
DEC C
DB "Enter First Location in Eprom to"
DB 0Dh
DB "be Blown"
DB 0Dh
NOP
CALL ALPNU
LD (TAB+6),DE
LD HL,(TAB+6)
LD DE,(TAB+4)
LD BC,CF07h
OUT (C),B ; port B control to bit mode
LD B,40h
OUT (C),B ; B0:B5=output, B6=input
NEXTW: LD BC,0F06h
OUT (C),B ; port A control to output mode
LD C,04h ; port A data
OUT (C),L ; output L on port A
LD BC,0805h ; port B data
EX AF,AF
OUT (C),B ; 00001000, data direction write
LD B,09h
ADD HL,BC ; ?
OUT (C),B ; 00001001, enable data bus
LD B,0Bh
OUT (C),B ; 00001011, low address strobe
LD B,08h
EX AF,AF
OUT (C),B ; 00001000, disable data bus
LD C,04h ; port A data
OUT (C),H ; output H on port A
LD H,C
LD BC,0905h ; port B data
OUT (C),B ; 00001001, enable data bus
LD B,0Dh
OUT (C),B ; 00001101, high address strobe
LD B,C ; ?
LD B,08h
OUT (C),B ; 00001000, disable data bus
LD BC,0004h ; port A data
OUT (C),B ; output 00h on port A
LD A,0FFh
OUT (06h),A ; port A control to bit mode
OUT (06h),A ; A0:A7=input
LD BC,0005h ; port B data
OUT (C),B ; 00000000, data direction read
LD B,01h
OUT (C),B ; 00000001, enable data bus
IN A,(04h) ; read data on port A into A reg
PUSH AF
PUSH DE
LD A,D
OR E
JP Z,BLOW ; jump to blow EPROM fuse routine
POP DE
POP AF
CP 0FFh
JP NZ,FAIL ; indicate faulty EPROM
INC HL
DEC DE
JP NEXTW ; next byte to write
BLOW: LD HL,(TAB+0)
LD BC,(TAB+4)
LD DE,(TAB+6)
COMB: PUSH BC
LD A,B
OR C
JP Z,ENDP ; quit when finished
LD BC,0F06h
OUT (C),B ; port A control to output mode
LD BC,CF07h
OUT (C),B ; port B control to bit mode
LD B,40h
OUT (C),B ; B0:B5=output, B6=input
LD C,04h
OUT (C),E ; output E on port A
LD BC,0805h
OUT (C),B ; 00001000, data direction write
LD B,09h
OUT (C),B ; 00001001, enable data bus
LD B,0Bh
OUT (C),B ; 00001011, low address strobe
LD B,08h
OUT (C),B ; 00001000, disable data bus
LD C,04h ; port A data
OUT (C),D ; output D reg on port A
LD BC,0905h ; port B data
OUT (C),B ; 00001001, enable data bus
LD B,0Dh
OUT (C),B ; 00001101, high address strobe
LD B,18h
OUT (C),B ; 00011000, disable data bus, VPP on
LD BC,0004h ; port A data
OUT (C),B ; output 00h on port A
LD B,(HL)
OUT (C),B ; output (HL) on port A
LD BC,1905h ; port B data
OUT (C),B ; 00011001, enable data bus
LD B,39h
OUT (C),B ; 00111001, raise program pulse high
NOP
NOP
NOP
NOP
NOP
LD B,19h
OUT (C),B ; 00011001, drop program pulse low
LD B,15h
WAIT: LD A,0FFh ; delay, instead of polling program pulse B6
PUSH AF
PUSH BC
RST 0x38
POP BC
POP AF
DEC B
LD A,B
CP 00h
JP NZ,WAIT
POP BC
DEC BC
INC DE
INC HL
JP COMB
;
; EPROM Faulty Error Message
;
FAIL: RST 0x28
DB 0Dh
DB 0Dh
DB 22h ; '"'
DB "EPROM FAULTY"
DB 22h ; '"'
NOP
JP ENDP
LD L,C
LD B,E
;
; HEX Alphanumeric to Binary Routine
; Result returned in DE register
;
ALPNU: LD B,00h
ST: RST 0x08
CP 3Ah ; ':'
JP P,ALPHA
CP 30h ; '0'
JP M,ALPHA
SUB 30h ; '0'
JP PRL
ALPHA: CP 47h ; 'G'
JP P,ST
CP 41h ; 'A'
JP M,ST
SUB 37h ; '7'
JP PRL
PRL: PUSH AF
RST 0x18
LD A,D
LD A,B
CP 00h
JP Z,RTA
CP 01h
JP Z,RTB
CP 02h
JP Z,RTC
CP 03h
JP Z,RTD
RTA: POP AF
RL A
RL A
RL A
RL A
LD D,A
JP LAST
RTB: POP AF
ADD A,D
LD D,A
JP LAST
RTC: POP AF
RL A
RL A
RL A
RL A
LD E,A
JP LAST
RTD: POP AF
ADD A,E
LD E,A
RET
LAST: INC B
JP ST
;
; End of the program
;
ENDP: JP NEW