10 ! HP-9915 EPROM data file to Intel format 20 ! Version 0.b 16/1/05 JAS 30 ! #### Outline Program Structure #### 40 ! Procedure - Read filename for EPROM data file 50 ! Maximum size of 94 records. 60 ! Each record contains 1 integer and 1 string of 258 bytes. 70 ! Only first integer is used, contains last valid record number. 80 ! First string is the directory, remaining 93 are for program storage. 90 ! Initial version of program adds 1 Basic program to directory 100 ! later versions will sort into size for 2732 EPROM 110 ! Procedure - Read Source EPROM data file 120 ! Procedure - Close EPROM data file 130 ! Procedure - Read data from EPROM data file 140 ! Procedure - Output in Intel Hex format to PRINT device 150 ! ***** MAIN PROGRAM START ************ 160 ! Define variables 170 COM A$[258] ! contains directory 175 A$="" ! Allocate space 180 DIM T$[258] ! contains current program record extracted from P$ 185 ! P$ should be 24*1024, reduced to avoid MEM OVR error 190 DIM P$[20480] 200 M=0 ! M - used for current size of EPROM data file in record 210 DISP "HP-9915 EPROM Data to Intel Hex" 220 DISP "-------------------------------" 230 DISP 240 DISP "Program uses an interim data" 250 DISP "file for the final EPROM" 260 DISP "contents." 270 ! Read name of EPROM data file into E$ 280 DISP "Enter filename for EPROM data" 290 DISP "file, (1 to 10 chars)" 300 INPUT E$ 310 IF LEN(E$)>10 THEN 280 320 ! Read back current record count and directory from EPROM data file 330 ASSIGN# 1 TO E$ 340 READ# 1,1 ; M,A$ 350 ASSIGN# 1 TO * 360 ! Display current EPROM file directory 370 DISP "EPROM data file contains";M;"records." 380 I=0 @ DISP "EPROM data file directory:" 390 IF A$[I*8+8,I*8+8]=CHR$(0) THEN N=I @ GOTO 450 ! Empty entry, 400 ! go and write out program data 410 DISP A$[I*8+1,I*8+6];" "; 420 I=I+1 430 IF I=32 THEN DISP @ DISP "Directory full! (max 32)" @ GOTO 450 440 GOTO 390 @ ! Go and look at next directory entry 450 ! Output program records and checksum, into P$ via T$ 455 DISP @ DISP 460 DISP "Enter Y to continue" 470 INPUT Q$ 480 P$="" ! Used to hold all EPROM data 490 DISP "Reading EPROM data file ";E$ 500 ASSIGN# 1 TO E$ ! Open EPROM data file 510 FOR I=1 TO M 520 READ# 1,I ; J,T$ ! Read in next data record 530 DISP T$ 540 P$=P$&T$ 550 NEXT I 560 DISP "Next stage is to PRINT Intel Hex file" 570 DISP "Enter Y to continue" 580 INPUT Q$ 590 ! format83.c hack, based on Erik Lindberg code Sep 17 1987 600 DIM L$[256] ! 128 * 2 hex digits, in place of buffer[128] 610 DIM C$[4] ! Temp store for character to hex eg taken from P$ 620 P=1 ! pointer into P$ 630 L=LEN(P$) 640 R=16 ! REC 00x10 650 C=1 660 A=0 ! address=0 670 I=0 680 IF P>L THEN 950 ! while c!= EOF, exit while loop if reached EOF 690 S=0 ! sum = 0 700 L$="" ! line=buffer 710 I=0 ! for(i=0;iL THEN GOTO 800 ! reached EOF so exit loop 740 C=NUM(P$[P,P]) ! value of position P 750 P=P+1 ! Move pointer to next character. If P>L then reached EOF 760 C$=DTH$(C) ! convert decimal to hex eg 00B3 770 L$=L$&C$[3,4] ! Append 2 hex digits to buffer 780 S=S+C ! sum += c 790 I=I+1 @ GOTO 720 ! next iteration of for loop 800 IF I=0 THEN 940 ! if (i) carry on, else reached end 810 S=S+INT(A/256) ! sum += address >>8 820 S=S+BINAND(A,255) ! sum += address & 0xff 830 S=S+I ! sum += i 840 PRINT ":"; 850 C$=DTH$(I) 860 PRINT C$[3,4];! puthex(i,2) 870 C$=DTH$(A) 880 PRINT C$;! puthex(address,4) 890 A=A+I ! address += i 900 PRINT "00";! puthex(0,2) 910 PRINT L$; 920 C$=DTH$(0-S) 930 PRINT C$[3,4] ! puthex(0-sum,2); printf("\n") 940 GOTO 680 ! end of while loop, start next record 950 PRINT ":00000001FF" 960 DISP "End of format83 routine" 970 DISP "END OF RUN" 980 END