; name prom32 ; ; 2732 prom programmer control program ; sdos environment ; 9/27/79 ; ; version 1.3 CP/M compatible 8/26/80 ; ; entered from printed listing 2/27/86 by JCS ; ;system equates .Z80 ; exit equ 0h tbase equ 100h data equ 68h ladd equ 69h hactl equ 6Ah rbout equ 0 fdos equ 5 fcb equ 5Ch buffer equ 80h open equ 15 close equ 16 read equ 20 setdma equ 26 nbytes equ 128 loops equ 100 ; ; ; ; ASEG ; ; psect abs ; org tbase + 3 ;start at 100h ; ; ; ; program prom entry point ; ; ; ppg: ld sp,spval ld hl,msg1 call ptxt ; "prom32 version 1.3" ld e,25h call conin cp 31h jr c,setdly ld e,32h jr c,setdly ld e,4Ah setdly: ld a,e ld (dlay),a ld a,nbytes ld (bcount),a xor a ;************ PAGE 2 ************************** ld (fopen),a ppg0: ld sp,spval xor a ;clear acc or 20h ;strobe off out (hactl),a call crlf ld hl,msg2 call ptxt ; "READY TO LOAD A FILE ?" ld hl,0 ld (scr1),hl ;clear byte counter call yorn jp nc,read2 ;if not, chk read ppg0b: call crlf ld a,(fopen) or a jr nz,ppg0c ld c,open ld de,fcb call fdos cp 255 jr nz,ppg0c ld hl,msg10 call ptxt jp rentry ppg0c: ld c,setdma ld de,buffer call fdos ld hl,msg3 call ptxt ; "HEX LOAD ADDRESS, # BYTES" call scan ;collect data ld a,(nxchr) cp '.' jr z,ppg0b ld hl,msg12 call ptxt ld hl,(opr1) call paddr call crlf call thdr ; read addr/#bytes 1st line push hl ld de,(opr1) ;load address entered ld a,(opcnt) and a jr z,ppg0A ; if no opr's entered sbc hl,de ;compute offset push hl pop de ;offset reg ppg0a: pop hl ld (scr3),de ;save offset jr ppg2 ppg1: call thdr ;load addr/# bytes ppg2: ld de,(scr3) or a ;clear carry sbc hl,de ;subtract offset ppg3: call twdg ;read a byte ld (hl),a ;store it ld (last),hl inc hl ;********************** PAGE 3 **************** push hl ld hl,(scr1) ;byte counter inc hl ld (scr1),hl pop hl djnz ppg3 ;read entire line call twdg ;read checksum xor a add a,c jr z,ppg4 push hl ld hl,msg13 call ptxt call paddr ;checksum error pop hl ppg4: ld hl,(scr1) ld bc,(opr2) ; # of bytes to read dec hl ; if 0, then FFFF dec bc and a sbc hl,bc jp c,ppg1 ;if more, jump ppg10: ld hl,msg14 call ptxt ld hl,(last) call paddr ppg10a: call crlf ld hl,msg4 call ptxt ; "READY TO PROGRAM A PROM ?" call yorn jp nc,rentry ppg11: call crlf ld hl,msg5 call ptxt ; "MEM START,MEM END,PROM START" call scan ld a,(nxchr) cp '.' ;if '.' exit jr z,ppg11 jp prog ; ; ; thdr: call fread ;look for ':' cp ':' jr nz,thdr xor a ;clear checksum ld c,a call twdg and a ;is record length 0? jr z,thdr1 ld b,a call twdg ;get first byte of address ld h,a call twdg ;get second byte ld l,a call twdg ;get record type ret thdr1: pop af ;*********************** PAGE 4 *************** jp ppg10 ; ; yorn: call echo ld c,a cp '.' jp z,rentry or a cp 'N' ret z cp 'Y' jr nz,yorn scf ret ; ; const: push bc ;call sdos console status push de push hl ld c,0Bh call 5 or a pop hl pop de pop bc ret ; echo: conin: push bc push de push hl ld c,1 ; call sdos console input call 5 pop hl pop de pop bc ret ; conout: push de push bc push hl ld e,c ld c,02 call 5 pop hl pop bc pop de ret ; rentry: xor a out (hactl),a call crlf ld a,(fopen) or a jp z,exit ld c,close ld de,fcb call fdos ;**************** PAGE 5 ********************** jp exit ; ; paddr: ld a,h call pacc ld a,l jp pasp ; ; ; msg1: defm 'PROM-32 VERSION 1.3' defb 0Ah,0Dh,0Ah,0Dh defm 'IS THIS SYSTEM RUNNING 2.0, 2.5, OR 4.0 ?' defb 0Ah,0Dh defm '(2.0 - 0, 2.5 - 1, 4.0 - 2)' defw 0Dh,0Ah defb 03h msg2: defm 'READY TO LOAD A FILE (Y/N)?' defb 03h msg3: defm 'HEX LOAD ADDRESS, # BYTES: ' defb 03h msg4: defm 'READY TO PROGRAM A PROM (Y/N)?' ;************ PAGE 6 ******** defb 03h msg5: defm 'MEMORY START,MEMORY END,PROM START: ' defb 03h msg6: defm 'READY TO READ A PROM (Y/N)?' defb 03h msg10: defm 'FILE NOT FOUND' defb 03h msg11: defm 'ATTEMPTING TO READ PAST END OF FILE' defb 03h msg12: defm 'LOAD START ADDRESS= ' defb 03h msg13: defm 'CHECKSKUM ERROR AT LOCATIONS ' defb 03h msg14: defm 'LOAD END ADDRESS= ' defb 03h ;********** PAGE 7 ************ ; ; ; ; ; prom read sequence ; ; ; read2: call crlf ;read prom into memory ld hl,msg6 call ptxt ;"ready to read (y/n)?" call yorn jp nc,ppg10a ;no, then program read0: call crlf ld hl,msg5 call ptxt ;"mem start, mem end, prom start" call scan ;input parameters ld a,(nxchr) cp '.' jr z,read0 call rdset read1: call pread ;read a byte of prom ld (hl),a ;save byte in mem call adcmp ;inc addr and compare jr nz,read1 ;if not end, then jump jp ppg10a ;when complete, return ; ; ; ; ; inc hl & de then compare hl with (ix) ; exit with zero flag set if equal ; ; adcmp: inc de ;inc prom address inc hl push de push hl ;save hl & de ld de,(opr2) ;get ram end addr inc de and a sbc hl,de ;compare pop hl pop de ret ; ; ; ; ; programming sequence ;************************* PAGE 8 ************* ; ; prog: call rdset prog1: call pread ;read a byte (prom) cp 0FFh ;check for erased bytes jr nz,prog2 ;if not erased jump prg1a: call adcmp ;inc addr & check for end jr nz,prog1 ;loop until end jr prog3 ;go program prom prog2: push af push hl ld hl,msg7 call ptxt ;"not erased" pop hl pop af call prter ;print bad location call echo ;read from console ld c,a cp '.' ;check for period jr z,prg2a ;exit cp 'C' ;check for 'C' jr z,prog3 ;continue if 'C' entered jr prg1a ;if not, print next error prg2a: ld a,20h out (hactl),a jp ppg0 prog3: call crlf prog4: ld hl,(opr1) ;set mem start address ld de,(opr3) ;set prom start addr ld a,d or 0E0h ld d,a prog5: ld a,d set 6,a out (hactl),a call pprog ;program one byte call const jr z,prog5a call conin cp '.' jr z,prog9 prog5a: call adcmp ;inc addr & check end jr nz,prog5 ;finish this loop prog6: ld a,20h out (hactl),a ;turn off all control lines prog6a: call rdset prog7: call pread ;read prom data cp (hl) jr nz,prog8 ;if not match, jump prg7a: call adcmp ;check for end jr nz,prog7 jr prg2a ;exit, complete prog8: push af push hl ld hl,msg8 call ptxt ;"BAD LOCATION" pop hl call const jr z,prog8a call conin cp '.' ;*********************** PAGE 9 *************** jr z,prg2a prog8a: pop af call prter ;print error message jr prg7a ;print all bad locations prog9: ld hl,msg9 call ptxt ;aborted jr prg2a ; ; ; ; pulse one prom location ; ; pprog: ld a,e out (ladd),a ;latch lsb of address ld a,d out (hactl),a ld a,(hl) ;fetch data out (data),a ;output data ld a,d res 5,a ;turn on program pulse out (hactl),a ld a,(dlay) ; 2.0 mhz - 25h ; 2.5 mhz - 32h ; 4.0 mhz - 4Ah call delay ; 50 millisec delay ld a,d set 5,a ; prog pulse off out (hactl),a ret ; delay: ld b,191 delay1: djnz delay1 dec a jr nz,delay ret ; ; rdset: ld hl,(opr1) ld de,(opr3) ld a,d and 0Fh set 5,a ld d,a ret ; ; ; read one location of prom ; ; pread: ld a,e out (ladd),a ;latch lsb of address ld a,d out (hactl),a res 5,a out (hactl),a in a,(data) push af ld a,d out (hactl),a pop af ret ; ; ; PRINTS ADDR/BAD DATA/GOOD DATA ; OF ERROR LOCATION ; ; prter: ld b,a ld a,d and 0Fh call pacc ;print msb of addr ld a,e call pacc ;print lsb of addr ld c,20h call conout ld a,b call pacc ;print bad data ld c,20h call conout ld a,(hl) call pacc ;print good data call crlf ret ; ; ; ; msg7: defm 'NOT ERASED ' defb 03h msg8: defm 'BAD LOC ' defb 03h msg9: defm 'ABORTED' defb 03h ; ; ; ; twdg-read and convert 2 digits to binary ; ; twdg: call fread ;read a char, 1st digit call asbin ;ascii to binary rlca rlca rlca rlca push bc ;save c reg (cksm) ld c,a ;save 1st digit call fread ;2nd digit call asbin or c ;or in msb's pop bc ;restore cksm push af ;save acc****************** PAGE 11 *********** add a,c ;add in 2 digits to cksm ld c,a pop af ;restore acc ret ; ; ; ; ; ascii to binary conversion ; ; asbin: sub 030h cp 10 ret M sub 7 ret ; ; ; ; ;******************************* PAGE 12 ******************************** ; (this line fills in for missing source code line) ; ; pasp: push bc call pacc call space call crlf pop bc ret ; ; ; crlf: ld c,0Dh call conout ld c,0Ah jp conout ; ; space: ld C,' ' jp conout ; ; ; ; ; ; print text ; ; ptxt: ld a,(hl) ;fetch a byte cp 3 ret z ld c,a call conout inc hl jp ptxt ; ; ; print accumulator ; ; pacc: push af rrca rrca rrca rrca call prval pop af ; ; prval: and 0Fh add a,90h daa adc a,40h daa ld c,a jp conout ;print it ; ;****************************** PAGE 13 *************************************** ; ; ; check for valid hex character ; ; aorn: cp '0' jp c,aorn2 ;jump if < 30h cp '9'+1 jp c,aorn1 ;jump if < 3Ah cp 'A'-1 jp c,aorn2 ;jump if < 'A' cp 'F'+1 jp nc,aorn2 ;jump if < 'G' aorn1: xor a ret ;valid data ret aorn2: xor a inc a ret ;not hex char ; ; ; check for terminator ; ; space, comma, or carriage return ; ; termck: cp ' ' ret z cp ',' ret z cp '.' jp z,tchk0 cp 0Dh ret nz tchk0: push bc call crlf pop bc xor a ret ; ; ; scan for operand from keyboard ; ; ; exit with data in hl, and terminator ; in c. if valid data, return with zero ; flag set. b contains # of characters entered. ; ; keyin: ld hl,0 ld b,l key1: call echo ld c,a inc b ;inc char count call termck ret z ; if terminator, return call aorn ;valid data check ret nz ;if not return ld a,c ;************************ PAGE 14 ************* call asbin ;convert to binary add hl,hl add hl,hl add hl,hl add hl,hl ;shift 4 bits add a,l ld l,a jp key1 ; ; ; ; invcmd: ld c,'?' call conout ld a,'.' ld (nxchr),a ret ; ; ; ; ;scan -- scans the operands input from the ; console. the operands are saved in op1, ; as the arguments to execute their commands. ; scan: xor a ;initialize ld hl,oprs ;clear operands push hl pop ix ;ix=pointer to operands ld (hl),a ld bc,9 ld de,oprs+1 ldir ld (opcnt),a scan1: call keyin ;get one operand jp nz,invcmd ld a,c ld (nxchr),a cp ' ' jr z,scan2 cp ',' jr z,scan2 dec b ret z ;if no data, ret scan2: ld (ix),l ld (ix+1),h ld a,(opcnt) inc a ld (opcnt),a inc ix inc ix ;point to next opr ld a,c cp ' ' jr z,scan1 cp ',' jr z,scan1 ret ;*********************************** PAGE 15 ********************************** ; ; fread: push hl push de push bc ld a,(bcount) cp nbytes jr nz,fread1 ld c,read ld de,fcb call fdos ;lead file or a jr nz,ferror xor a fread1: ld hl,buffer ld e,a inc a ld (bcount),a ld d,0 add hl,de ;point to next data ld a,(hl) pop bc pop de pop hl ret ferror: pop bc pop de pop hl ld hl,msg11 call ptxt ;attempt to read past eof jp rentry ; dlay: defs 1 scr1: defs 1 scr2: defs 1 scr3: defs 1 opcnt: defs 1 nxchr: defs 1 fopen: defs 1 bcount: defs 1 last: defs 2 oprs: defs 6 opr1 equ oprs opr2 equ oprs+2 opr3 equ oprs+4 spval equ oprs+100h ; ; ; end