Hand Held Products 71M/M eprom carrier question
|
09-08-2020, 05:32 PM
Post: #21
|
|||
|
|||
RE: Hand Held Products 71M/M eprom carrier question
Richard: I used this program to convert a ROM dump into an intel hex file suitable for burning an EPROM. It is a one-off thing and has no error checking; it hasn't been cleaned up either, but it did the job for me.
/* dmp2hex.c : convert a nibble dump from the HP-71B DUMPROM BASIC program into an intel HEX format file. Syntax is $ dmp2hex infile.dmp > outfile.hex The output is appropriate to burn an EPROM for the Hand Held Products 71M/M EPROM carrier for the card reader slot. A rom dump is just the nibbles in the Saturn cpu memory map in order of increasing address (as returned by PEEK$), in the form of a text file with 64 characters per line, each character the ASCII hex digit {0-9, A-F} for each nibble. But the data in the EPROM differs from this in that the most significant nibble in each byte is the higher-addressed nible in the memory map, and also in that the data is negated in the ROM. Thus, a 16 nibble sequence in a ROM such as B3DDDDDEE4642513 must be coded in the EPROM like these eight consecutive bytes C4 22 22 12 B1 B9 AD CE DF That is, C is the 1-complement of 3, 4 is the 1-complement of B, 2 is the 1-complement of the fourth nibble in the sequence (a D) and so on. Carlos E. Murillo-Sanchez 2020-06-15. Just a quick hack without much error checking. Version 1.0 */ #include <stdio.h> #include <string.h> unsigned char hex2nibble(unsigned char a) { unsigned char b; if (a >= 48 & a <= 57) { b = a - 48; } else if ( a >= 65 & a <= 70) { b = a - 55; } else if ( a>= 97 & a <= 102 ) { b = a - 87; } else { fprintf(stderr, "Invalid ASCII character representation of hex value %s\n", a); } return b; } unsigned char nibble2hex(unsigned char a) { unsigned char b; b = a & 0x0F; if (b < 10) { b = b + 0x30; } else { b = b + 55; } return b; } int main (argc, argv, envp) int argc; char **argv; char **envp; { char *ifile; char *program; FILE *fp; unsigned char linein[66]; unsigned char nibbles[64]; unsigned char bytes[16]; unsigned char hexnibbles[64]; unsigned char hexbytes[64]; unsigned char tmpchar1, tmpchar2, tmpchar3, tmpchar4; int lines, i, j, k; program = strrchr (argv[0], '/'); if (argc < 2) { printf("\nUsage: %s inputfile.dmp > outputfile.hex\n\n", program); return 0; } fp = fopen(argv[1], "r"); if (fp == 0) { printf("%s: Could not open %s file for input.\n", program, argv[1]); return 1; } /*count the lines*/ lines = 0; while (fscanf(fp, "%s", linein) == 1) { if (strlen(linein) > 0) { lines++; } } fclose(fp); /* do actual processing */ fp = fopen(argv[1], "r"); /* First write header of hex file */ printf(":020000040000FA\n"); /* Then write data */ k = 0; while (fscanf(fp, "%s", linein) == 1) { /* Convert string of ascii hex values of nibbles into bytes */ for (i=0; i<64; i++) { nibbles[i] = hex2nibble(linein[i]); } /* swap and complement every two nibbles */ for (i=0; i<32; i++) { tmpchar1 = nibbles[2*i]; tmpchar2 = nibbles[2*i+1]; tmpchar1 = (~tmpchar1) & 0x0F; tmpchar2 = (~tmpchar2) & 0x0F; nibbles[2*i] = tmpchar2; nibbles[2*i+1] = tmpchar1; } /* Convert to string of hex values */ for (i=0; i<64; i++) { hexbytes[i] = nibble2hex(nibbles[i]); } /* Output two lines of intel hex file format */ for (i=0; i<2; i++) { printf(":10"); tmpchar1 = (unsigned char) ((16*k) & 0xFF); tmpchar1 = tmpchar1 + (unsigned char) ( k / 16); tmpchar1 = tmpchar1 + 16; tmpchar2 = (unsigned char) ( k / 16 ); tmpchar3 = nibble2hex(tmpchar2 >> 4); tmpchar4 = nibble2hex(tmpchar2); printf("%c%c", tmpchar3, tmpchar4); tmpchar2 = (unsigned char) ((16*k) & 0xFF); tmpchar3 = nibble2hex(tmpchar2 >> 4); tmpchar4 = nibble2hex(tmpchar2); printf("%c%c", tmpchar3, tmpchar4); printf("00"); for (j=0; j<16; j++) { printf("%c%c", hexbytes[32*i+2*j], hexbytes[32*i+2*j+1]); tmpchar2 = 16*nibbles[32*i+2*j] + nibbles[32*i+2*j+1]; tmpchar1 = tmpchar1 + tmpchar2; } tmpchar1 = ~tmpchar1 + 1; tmpchar2 = tmpchar1 >> 4; printf("%c%c\n", nibble2hex(tmpchar2), nibble2hex(tmpchar1)); k++; } } printf(":00000001FF\n"); fclose(fp); return 0; } |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)