1. New Features in 2.10-2 The build procedures have changed. There is only one UNIX makefile. To compile without Ethernet support, simply type gmake {target|all} To compile with Ethernet support, type gmake USE_NETWORK=1 {target|all} The Mingw batch files require Mingw release 2 and invoke the Unix makefile. There are still separate batch files for compilation with or without Ethernet support. 1.1 SCP and Libraries - The EVAL command will evaluate a symbolic type-in and display it in numeric form. - The ! command (with no arguments) will launch the host operating system command shell. The ! command (with an argument) executes the argument as a host operating system command. (Code from Mark Pizzolato) - Telnet sessions now recognize BREAK. How a BREAK is transmitted dependent on the particular Telnet client. (Code from Mark Pizzolato) - The sockets library includes code for active connections as well as listening connections. - The RESTORE command will restore saved memory size, if the simulator supports dynamic memory resizing. 1.2 PDP-1 - The PDP-1 supports the Type 24 serial drum (based on recently discovered documents). 1.3 18b PDP's - The PDP-4 supports the Type 24 serial drum (based on recently discovered documents). 1.4 PDP-11 - The PDP-11 implements a stub DEUNA/DELUA (XU). The real XU module will be included in a later release. 1.5 PDP-10 - The PDP-10 implements a stub DEUNA/DELUA (XU). The real XU module will be included in a later release. 1.6 HP 2100 - The IOP microinstruction set is supported for the 21MX as well as the 2100. - The HP2100 supports the Access Interprocessor Link (IPL). 1.7 VAX - If the VAX console is attached to a Telnet session, BREAK is interpreted as console halt. - The SET/SHOW HISTORY commands enable and display a history of the most recently executed instructions. (Code from Mark Pizzolato) 1.8 Terminals Multiplexors - BREAK detection was added to the HP, DEC, and Interdata terminal multiplexors. 1.9 Interdata 16b and 32b - First release. UNIX is not yet working. 1.10 SDS 940 - First release. 2. Bugs Fixed in 2.10-2 - PDP-11 console must default to 7b for early UNIX compatibility. - PDP-11/VAX TMSCP emulator was using the wrong packet length for read/write end packets. - Telnet IAC+IAC processing was fixed, both for input and output (found by Mark Pizzolato). - PDP-11/VAX Ethernet setting flag bits wrong for chained descriptors (found by Mark Pizzolato). 3. New Features in 2.10 vs prior releases 3.1 SCP and Libraries - The VT emulation package has been replaced by the capability to remote the console to a Telnet session. Telnet clients typically have more complete and robust VT100 emulation. - Simulated devices may now have statically allocated buffers, in addition to dynamically allocated buffers or disk-based data stores. - The DO command now takes substitutable arguments (max 9). In command files, %n represents substitutable argument n. - The initial command line is now interpreted as the command name and substitutable arguments for a DO command. This is backward compatible to prior versions. - The initial command line parses switches. -Q is interpreted as quiet mode; informational messages are suppressed. - The HELP command now takes an optional argument. HELP <cmd> types help on the specified command. - Hooks have been added for implementing GUI-based consoles, as well as simulator-specific command extensions. A few internal data structures and definitions have changed. - Two new routines (tmxr_open_master, tmxr_close_master) have been added to sim_tmxr.c. The calling sequence for sim_accept_conn has been changed in sim_sock.c. - The calling sequence for the VM boot routine has been modified to add an additional parameter. - SAVE now saves, and GET now restores, controller and unit flags. - Library sim_ether.c has been added for Ethernet support. 3.2 VAX - Non-volatile RAM (NVR) can behave either like a memory or like a disk-based peripheral. If unattached, it behaves like memory and is saved and restored by SAVE and RESTORE, respectively. If attached, its contents are loaded from disk by ATTACH and written back to disk at DETACH and EXIT. - SHOW <device> VECTOR displays the device's interrupt vector. A few devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The TK50 (TMSCP tape) has been added. - The DEQNA/DELQA (Qbus Ethernet controllers) have been added. - Autoconfiguration support has been added. - The paper tape reader has been removed from vax_stddev.c and now references a common implementation file, dec_pt.h. - Examine and deposit switches now work on all devices, not just the CPU. - Device address conflicts are not detected until simulation starts. 3.3 PDP-11 - SHOW <device> VECTOR displays the device's interrupt vector. Most devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The TK50 (TMSCP tape), RK611/RK06/RK07 (cartridge disk), RX211 (double density floppy), and KW11P programmable clock have been added. - The DEQNA/DELQA (Qbus Ethernet controllers) have been added. - Autoconfiguration support has been added. - The paper tape reader has been removed from pdp11_stddev.c and now references a common implementation file, dec_pt.h. - Device bootstraps now use the actual CSR specified by the SET ADDRESS command, rather than just the default CSR. Note that PDP-11 operating systems may NOT support booting with non-standard addresses. - Specifying more than 256KB of memory, or changing the bus configuration, causes all peripherals that are not compatible with the current bus configuration to be disabled. - Device address conflicts are not detected until simulation starts. 3.4 PDP-10 - SHOW <device> VECTOR displays the device's interrupt vector. A few devices allow the vector to be changed with SET <device> VECTOR=nnn. - SHOW CPU IOSPACE displays the I/O space address map. - The RX211 (double density floppy) has been added; it is off by default. - The paper tape now references a common implementation file, dec_pt.h. - Device address conflicts are not detected until simulation starts. 3.5 PDP-1 - DECtape (then known as MicroTape) support has been added. - The line printer and DECtape can be disabled and enabled. 3.6 PDP-8 - The RX28 (double density floppy) has been added as an option to the existing RX8E controller. - SHOW <device> DEVNO displays the device's device number. Most devices allow the device number to be changed with SET <device> DEVNO=nnn. - Device number conflicts are not detected until simulation starts. 3.7 IBM 1620 - The IBM 1620 simulator has been released. 3.8 AltairZ80 - A hard drive has been added for increased storage. - Several bugs have been fixed. 3.9 HP 2100 - The 12845A has been added and made the default line printer (LPT). The 12653A has been renamed LPS and is off by default. It also supports the diagnostic functions needed to run the DCPC and DMS diagnostics. - The 12557A/13210A disk defaults to the 13210A (7900/7901). - The 12559A magtape is off by default. - New CPU options (EAU/NOEAU) enable/disable the extended arithmetic instructions for the 2116. These instructions are standard on the 2100 and 21MX. - New CPU options (MPR/NOMPR) enable/disable memory protect for the 2100 and 21MX. - New CPU options (DMS/NODMS) enable/disable the dynamic mapping instructions for the 21MX. - The 12539 timebase generator autocalibrates. 3.10 Simulated Magtapes - Simulated magtapes recognize end of file and the marker 0xFFFFFFFF as end of medium. Only the TMSCP tape simulator can generate an end of medium marker. - The error handling in simulated magtapes was overhauled to be consistent through all simulators. 3.11 Simulated DECtapes - Added support for RT11 image file format (256 x 16b) to DECtapes. 4. Bugs Fixed in 2.10 vs prior releases - TS11/TSV05 was not simulating the XS0_MOT bit, causing failures under VMS. In addition, two of the CTL options were coded interchanged. - IBM 1401 tape was not setting a word mark under group mark for load mode reads. This caused the diagnostics to crash. - SCP bugs in ssh_break and set_logon were fixed (found by Dave Hittner). - Numerous bugs in the HP 2100 extended arithmetic, floating point, 21MX, DMS, and IOP instructions were fixed. Bugs were also fixed in the memory protect and DMS functions. The moving head disks (DP, DQ) were revised to simulate the hardware more accurately. Missing functions in DQ (address skip, read address) were added. - PDP-10 tape wouldn't boot, and then wouldn't read (reported by Michael Thompson and Harris Newman, respectively) - PDP-1 typewriter is half duplex, with only one shift state for both input and output (found by Derek Peschel) 5. General Notes WARNING: V2.10 has reorganized and renamed some of the definition files for the PDP-10, PDP-11, and VAX. Be sure to delete all previous source files before you unpack the Zip archive, or unpack it into a new directory structure. WARNING: V2.10 has a new, more comprehensive save file format. Restoring save files from previous releases will cause 'invalid register' errors and loss of CPU option flags, device enable/ disable flags, unit online/offline flags, and unit writelock flags. WARNING: If you are using Visual Studio .NET through the IDE, be sure to turn off the /Wp64 flag in the project settings, or dozens of spurious errors will be generated. WARNING: Compiling Ethernet support under Windows requires extra steps; see the Ethernet readme file. Ethernet support is currently available only for Windows, Linux, NetBSD, and OpenBSD.
752 lines
15 KiB
C
752 lines
15 KiB
C
/*
|
|
* (C) Copyright 2002, Brian Knittel.
|
|
* You may freely use this program, but: it offered strictly on an AS-IS, AT YOUR OWN
|
|
* RISK basis, there is no warranty of fitness for any purpose, and the rest of the
|
|
* usual yada-yada. Please keep this notice and the copyright in any distributions
|
|
* or modifications.
|
|
*
|
|
* This is not a supported product, but I welcome bug reports and fixes.
|
|
* Mail to sim@ibm1130.org
|
|
*/
|
|
|
|
// ---------------------------------------------------------------------------------
|
|
// BINDUMP - dumps card deck files in assembler object format
|
|
//
|
|
// Usage:
|
|
/// bindump deckfile lists object header info & sector break cards
|
|
// bindump -v deckfile lists object data records as well
|
|
// bindump -p deckfile for system program, lists phase IDs in the deck
|
|
// bindump -s deckfile >outfile for system program, sorts the phases & writes to stdout
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#ifdef WIN32
|
|
# include <windows.h>
|
|
# include <io.h>
|
|
# include <fcntl.h>
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
#define BOOL int
|
|
#define TRUE 1
|
|
#define FALSE 0
|
|
#endif
|
|
|
|
typedef enum {R_ABSOLUTE = 0, R_RELATIVE = 1, R_LIBF = 2, R_CALL = 3} RELOC;
|
|
|
|
BOOL verbose = FALSE;
|
|
BOOL phid = FALSE;
|
|
BOOL sort = FALSE;
|
|
unsigned short card[80], buf[54], cardtype;
|
|
|
|
// bindump - dump a binary (card format) deck to verify sbrks, etc
|
|
|
|
void bail (char *msg);
|
|
void dump (char *fname);
|
|
void dump_data (char *fname);
|
|
void dump_phids (char *fname);
|
|
char *getname (unsigned short *ptr);
|
|
char *getseq (void);
|
|
int hollerith_to_ascii (unsigned short h);
|
|
void process (char *fname);
|
|
void show_raw (char *name);
|
|
void show_data (void);
|
|
void show_core (void);
|
|
void show_endc (void);
|
|
void show_81 (void);
|
|
void show_main (void);
|
|
void show_sub (void);
|
|
void show_ils (void);
|
|
void show_iss (void);
|
|
void show_end (void);
|
|
void sort_phases (char *fname);
|
|
void trim (char *s);
|
|
void unpack (unsigned short *card, unsigned short *buf);
|
|
void verify_checksum(unsigned short *buf);
|
|
|
|
int main (int argc, char **argv)
|
|
{
|
|
char *arg;
|
|
static char usestr[] = "Usage: bindump [-psv] filename...";
|
|
int i;
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
arg = argv[i];
|
|
if (*arg == '-') {
|
|
arg++;
|
|
while (*arg) {
|
|
switch (*arg++) {
|
|
case 'v':
|
|
verbose = TRUE;
|
|
break;
|
|
case 'p':
|
|
phid = TRUE; // print only phase ID's
|
|
break;
|
|
case 's':
|
|
sort = TRUE; // sort deck by phases, writing to stdout
|
|
break;
|
|
default:
|
|
bail(usestr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
arg = argv[i];
|
|
if (*arg != '-')
|
|
process(arg);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void process (char *nm)
|
|
{
|
|
#ifdef WIN32
|
|
WIN32_FIND_DATA fd;
|
|
HANDLE hFind;
|
|
char *c, buf[256];
|
|
|
|
if (strchr(nm, '*') == NULL && strchr(nm, '?') == NULL)
|
|
dump(nm);
|
|
|
|
else if ((hFind = FindFirstFile(nm, &fd)) == INVALID_HANDLE_VALUE)
|
|
fprintf(stderr, "No files matching '%s'\n", nm);
|
|
|
|
else {
|
|
if ((c = strrchr(nm, '\\')) == NULL)
|
|
c = strrchr(nm, ':');
|
|
|
|
do {
|
|
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
continue;
|
|
|
|
if (c == NULL)
|
|
dump(fd.cFileName);
|
|
else {
|
|
strcpy(buf, nm);
|
|
strcpy(buf + (c-nm+1), fd.cFileName);
|
|
dump(buf);
|
|
}
|
|
|
|
} while (FindNextFile(hFind, &fd));
|
|
|
|
FindClose(hFind);
|
|
}
|
|
#else
|
|
dump(nm); // on unices, sh globs for us
|
|
#endif
|
|
}
|
|
|
|
void dump (char *fname)
|
|
{
|
|
if (sort)
|
|
sort_phases(fname);
|
|
else if (phid)
|
|
dump_phids(fname);
|
|
else
|
|
dump_data(fname);
|
|
}
|
|
|
|
struct tag_card {
|
|
int phid, seq;
|
|
unsigned short card[80];
|
|
};
|
|
|
|
int cardcomp (const void *a, const void *b)
|
|
{
|
|
short diff;
|
|
|
|
diff = ((struct tag_card *) a)->phid - ((struct tag_card *) b)->phid;
|
|
|
|
return diff ? diff : (((struct tag_card *) a)->seq - ((struct tag_card *) b)->seq);
|
|
}
|
|
|
|
void sort_phases (char *fname)
|
|
{
|
|
int i, ncards, cardtype, len, seq = 0, phid;
|
|
struct tag_card *deck;
|
|
FILE *fd;
|
|
BOOL saw_sbrk = TRUE;
|
|
|
|
if ((fd = fopen(fname, "rb")) == NULL) {
|
|
perror(fname);
|
|
return;
|
|
}
|
|
|
|
fseek(fd, 0, SEEK_END);
|
|
len = ftell(fd); // get length of file
|
|
fseek(fd, 0, SEEK_SET);
|
|
|
|
if (len <= 0 || (len % 160) != 0) {
|
|
fprintf(stderr, "%s is not a binard deck image\n");
|
|
fclose(fd);
|
|
return;
|
|
}
|
|
|
|
ncards = len / 160;
|
|
|
|
if ((deck = (struct tag_card *) malloc(ncards*sizeof(struct tag_card))) == NULL) {
|
|
fprintf(stderr, "%s: can't sort, insufficient memory\n");
|
|
fclose(fd);
|
|
return;
|
|
}
|
|
|
|
phid = 0;
|
|
for (i = 0; i < ncards; i++) {
|
|
if (fread(deck[i].card, sizeof(card[0]), 80, fd) != 80) {
|
|
free(deck);
|
|
fprintf(stderr, "%s: error reading deck\n");
|
|
fclose(fd);
|
|
return;
|
|
}
|
|
|
|
unpack(deck[i].card, buf);
|
|
deck[i].seq = seq++;
|
|
deck[i].phid = phid;
|
|
|
|
verify_checksum(buf);
|
|
|
|
cardtype = (buf[2] >> 8) & 0xFF;
|
|
|
|
if (cardtype == 1 || cardtype == 2) { // start of deck is same as sector break
|
|
saw_sbrk = TRUE;
|
|
}
|
|
else if (cardtype == 0) {
|
|
fprintf(stderr, "%s is a core image deck\n");
|
|
free(deck);
|
|
fclose(fd);
|
|
return;
|
|
}
|
|
else if (cardtype == 0x0A && saw_sbrk) {
|
|
phid = (int) (signed short) buf[10];
|
|
if (phid < 0)
|
|
phid = -phid;
|
|
|
|
deck[i].phid = phid; // this belongs to the new phase
|
|
deck[i-1].phid = phid; // as does previous card
|
|
saw_sbrk = FALSE;
|
|
}
|
|
}
|
|
fclose(fd);
|
|
|
|
qsort(deck, ncards, sizeof(struct tag_card), cardcomp); // sort the deck
|
|
|
|
#ifdef WIN32
|
|
_setmode(_fileno(stdout), _O_BINARY); // set standard output to binary mode
|
|
#endif
|
|
|
|
for (i = 0; i < ncards; i++) // write to stdout
|
|
fwrite(deck[i].card, sizeof(card[0]), 80, stdout);
|
|
|
|
free(deck);
|
|
}
|
|
|
|
void dump_phids (char *fname)
|
|
{
|
|
FILE *fp;
|
|
BOOL first = TRUE;
|
|
BOOL saw_sbrk = TRUE, neg;
|
|
short id;
|
|
|
|
if ((fp = fopen(fname, "rb")) == NULL) {
|
|
perror(fname);
|
|
return;
|
|
}
|
|
|
|
printf("\n%s:\n", fname);
|
|
|
|
while (fread(card, sizeof(card[0]), 80, fp) > 0) {
|
|
unpack(card, buf);
|
|
verify_checksum(buf);
|
|
|
|
cardtype = (buf[2] >> 8) & 0xFF;
|
|
|
|
if (cardtype == 1 && ! first) { // sector break
|
|
saw_sbrk = TRUE;
|
|
continue;
|
|
}
|
|
else {
|
|
switch (cardtype) {
|
|
case 0x00:
|
|
printf(" This is a core image deck\n");
|
|
goto done;
|
|
break;
|
|
case 0x01:
|
|
case 0x02:
|
|
case 0x03:
|
|
case 0x04:
|
|
case 0x05:
|
|
case 0x06:
|
|
case 0x07:
|
|
case 0x0F:
|
|
break;
|
|
|
|
case 0x0A:
|
|
if (saw_sbrk) {
|
|
id = buf[10];
|
|
if (id < 0)
|
|
id = -id, neg = TRUE;
|
|
else
|
|
neg = FALSE;
|
|
printf(" : %3d / %02x%s\n", id, id, neg ? " (neg)" : "");
|
|
saw_sbrk = FALSE;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
show_raw("??? ");
|
|
}
|
|
}
|
|
done:
|
|
first = FALSE;
|
|
}
|
|
|
|
fclose(fp);
|
|
}
|
|
|
|
void dump_data (char *fname)
|
|
{
|
|
FILE *fp;
|
|
BOOL first = TRUE;
|
|
char str[80];
|
|
int i;
|
|
|
|
if ((fp = fopen(fname, "rb")) == NULL) {
|
|
perror(fname);
|
|
return;
|
|
}
|
|
|
|
printf("\n%s:\n", fname);
|
|
|
|
while (fread(card, sizeof(card[0]), 80, fp) > 0) {
|
|
unpack(card, buf);
|
|
verify_checksum(buf);
|
|
|
|
cardtype = (buf[2] >> 8) & 0xFF;
|
|
|
|
if (cardtype == 1 && ! first) { // sector break
|
|
for (i = 4; i < 72; i++)
|
|
str[i] = hollerith_to_ascii(card[i]);
|
|
|
|
str[i] = '\0';
|
|
trim(str+4);
|
|
printf("*SBRK %s\n", str+4);
|
|
continue;
|
|
}
|
|
else {
|
|
switch (cardtype) {
|
|
case 0x00:
|
|
if (first)
|
|
show_raw("CORE");
|
|
if (verbose)
|
|
show_core();
|
|
break;
|
|
|
|
case 0x01:
|
|
show_raw("ABS ");
|
|
show_main();
|
|
break;
|
|
case 0x02:
|
|
show_raw("REL ");
|
|
show_main();
|
|
break;
|
|
case 0x03:
|
|
show_raw("LIB ");
|
|
show_sub();
|
|
break;
|
|
case 0x04:
|
|
show_raw("SUB ");
|
|
show_sub();
|
|
break;
|
|
case 0x05:
|
|
show_raw("ISSL");
|
|
show_iss();
|
|
break;
|
|
case 0x06:
|
|
show_raw("ISSC");
|
|
show_iss();
|
|
break;
|
|
case 0x07:
|
|
show_raw("ILS ");
|
|
show_ils();
|
|
break;
|
|
case 0x0F:
|
|
show_raw("END ");
|
|
show_end();
|
|
break;
|
|
case 0x80:
|
|
show_raw("ENDC");
|
|
show_endc();
|
|
break;
|
|
case 0x81:
|
|
show_raw("81 ");
|
|
show_81();
|
|
break;
|
|
case 0x0A:
|
|
if (verbose)
|
|
show_data();
|
|
break;
|
|
default:
|
|
show_raw("??? ");
|
|
}
|
|
}
|
|
|
|
first = FALSE;
|
|
}
|
|
|
|
fclose(fp);
|
|
}
|
|
|
|
void show_data (void)
|
|
{
|
|
int i, n, jrel, rflag, nout, ch, reloc;
|
|
BOOL first = TRUE;
|
|
|
|
n = buf[2] & 0x00FF;
|
|
|
|
printf("%04x: ", buf[0]);
|
|
|
|
jrel = 3;
|
|
nout = 0;
|
|
rflag = buf[jrel++];
|
|
for (i = 0; i < n; i++) {
|
|
if (nout >= 8) {
|
|
rflag = buf[jrel++];
|
|
if (first) {
|
|
printf(" %s", getseq());
|
|
first = FALSE;
|
|
}
|
|
printf("\n ");
|
|
nout = 0;
|
|
}
|
|
reloc = (rflag >> 14) & 0x03;
|
|
ch = (reloc == R_ABSOLUTE) ? ' ' :
|
|
(reloc == R_RELATIVE) ? 'R' :
|
|
(reloc == R_LIBF) ? 'L' : '@';
|
|
|
|
printf("%04x%c ", buf[9+i], ch);
|
|
rflag << 2;
|
|
nout++;
|
|
}
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_core (void)
|
|
{
|
|
int i, n, nout;
|
|
BOOL first = TRUE;
|
|
|
|
n = buf[2] & 0x00FF;
|
|
|
|
printf("%04x: ", buf[0]);
|
|
|
|
nout = 0;
|
|
for (i = 0; i < n; i++) {
|
|
if (nout >= 8) {
|
|
if (first) {
|
|
printf(" %s", getseq());
|
|
first = FALSE;
|
|
}
|
|
printf("\n ");
|
|
nout = 0;
|
|
}
|
|
printf("%04x ", buf[9+i]);
|
|
nout++;
|
|
}
|
|
putchar('\n');
|
|
}
|
|
|
|
void info (int i, char *nm, char type)
|
|
{
|
|
if (nm)
|
|
printf("%s ", nm);
|
|
|
|
switch (type) {
|
|
case 'd':
|
|
printf("%d ", buf[i]);
|
|
break;
|
|
|
|
case 'x':
|
|
printf("%04x ", buf[i]);
|
|
break;
|
|
|
|
case 'b':
|
|
printf("%02x ", buf[i] & 0xFF);
|
|
break;
|
|
|
|
case 'n':
|
|
printf("%s ", getname(buf+i));
|
|
break;
|
|
|
|
default:
|
|
bail("BAD TYPE");
|
|
}
|
|
}
|
|
|
|
void show_main (void)
|
|
{
|
|
printf(" ");
|
|
info(2, "prec", 'b');
|
|
info(4, "common", 'd');
|
|
info(6, "work", 'd');
|
|
info(8, "files", 'd');
|
|
info(9, "name", 'n');
|
|
info(11, "pta", 'x');
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_sub (void)
|
|
{
|
|
int i, n;
|
|
|
|
printf(" ");
|
|
info( 2, "prec", 'b');
|
|
|
|
n = buf[5] / 3;
|
|
for (i = 0; i < n; i++) {
|
|
info( 9+3*i, "ent", 'n');
|
|
info(11+3*i, NULL, 'x');
|
|
}
|
|
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_iss (void)
|
|
{
|
|
printf(" ");
|
|
info(12, "level", 'd');
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_ils (void)
|
|
{
|
|
printf(" ");
|
|
info( 2, "prec", 'b');
|
|
info( 5, "nint6", 'd');
|
|
info( 9, "ent", 'n');
|
|
info(11, NULL, 'x');
|
|
info(14, "nint", 'd');
|
|
info(15, "il1", 'd');
|
|
info(16, "il2", 'd');
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_end (void)
|
|
{
|
|
printf(" ");
|
|
info(0, "size", 'd');
|
|
info(3, "pta", 'x');
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_endc(void)
|
|
{
|
|
printf(" ");
|
|
info(52, "IX3", 'x');
|
|
info(53, "pta", 'x');
|
|
putchar('\n');
|
|
}
|
|
|
|
void show_81(void)
|
|
{
|
|
}
|
|
|
|
void show_raw (char *name)
|
|
{
|
|
int i;
|
|
printf("*%s", name);
|
|
|
|
for (i = 0; i < 12; i++)
|
|
printf(" %04x", buf[i]);
|
|
|
|
printf(" %s\n", getseq());
|
|
}
|
|
|
|
char * getseq (void)
|
|
{
|
|
static char seq[10];
|
|
int i;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
seq[i] = hollerith_to_ascii(card[72+i]);
|
|
|
|
seq[i] = '\0';
|
|
return seq;
|
|
}
|
|
|
|
|
|
void bail (char *msg)
|
|
{
|
|
fprintf(stderr, "%s\n", msg);
|
|
exit(1);
|
|
}
|
|
|
|
void unpack (unsigned short *icard, unsigned short *obuf)
|
|
{
|
|
int i, j;
|
|
unsigned short wd1, wd2, wd3, wd4;
|
|
|
|
for (i = j = 0; i < 54; i += 3, j += 4) {
|
|
wd1 = icard[j];
|
|
wd2 = icard[j+1];
|
|
wd3 = icard[j+2];
|
|
wd4 = icard[j+3];
|
|
|
|
obuf[i ] = (wd1 & 0xFFF0) | ((wd2 >> 12) & 0x000F);
|
|
obuf[i+1] = ((wd2 << 4) & 0xFF00) | ((wd3 >> 8) & 0x00FF);
|
|
obuf[i+2] = ((wd3 << 8) & 0xF000) | ((wd4 >> 4) & 0x0FFF);
|
|
}
|
|
}
|
|
|
|
void verify_checksum (unsigned short *obuf)
|
|
{
|
|
// unsigned short sum;
|
|
|
|
if (obuf[1] == 0) // no checksum
|
|
return;
|
|
|
|
// if (sum != card[1])
|
|
// printf("Checksum %04x doesn't match card %04x\n", sum, card[1]);
|
|
}
|
|
|
|
typedef struct {
|
|
unsigned short hollerith;
|
|
char ascii;
|
|
} CPCODE;
|
|
|
|
static CPCODE cardcode_029[] =
|
|
{
|
|
0x0000, ' ',
|
|
0x8000, '&', // + in 026 Fortran
|
|
0x4000, '-',
|
|
0x2000, '0',
|
|
0x1000, '1',
|
|
0x0800, '2',
|
|
0x0400, '3',
|
|
0x0200, '4',
|
|
0x0100, '5',
|
|
0x0080, '6',
|
|
0x0040, '7',
|
|
0x0020, '8',
|
|
0x0010, '9',
|
|
0x9000, 'A',
|
|
0x8800, 'B',
|
|
0x8400, 'C',
|
|
0x8200, 'D',
|
|
0x8100, 'E',
|
|
0x8080, 'F',
|
|
0x8040, 'G',
|
|
0x8020, 'H',
|
|
0x8010, 'I',
|
|
0x5000, 'J',
|
|
0x4800, 'K',
|
|
0x4400, 'L',
|
|
0x4200, 'M',
|
|
0x4100, 'N',
|
|
0x4080, 'O',
|
|
0x4040, 'P',
|
|
0x4020, 'Q',
|
|
0x4010, 'R',
|
|
0x3000, '/',
|
|
0x2800, 'S',
|
|
0x2400, 'T',
|
|
0x2200, 'U',
|
|
0x2100, 'V',
|
|
0x2080, 'W',
|
|
0x2040, 'X',
|
|
0x2020, 'Y',
|
|
0x2010, 'Z',
|
|
0x0820, ':',
|
|
0x0420, '#', // = in 026 Fortran
|
|
0x0220, '@', // ' in 026 Fortran
|
|
0x0120, '\'',
|
|
0x00A0, '=',
|
|
0x0060, '"',
|
|
0x8820, 'c', // cent
|
|
0x8420, '.',
|
|
0x8220, '<', // ) in 026 Fortran
|
|
0x8120, '(',
|
|
0x80A0, '+',
|
|
0x8060, '|',
|
|
0x4820, '!',
|
|
0x4420, '$',
|
|
0x4220, '*',
|
|
0x4120, ')',
|
|
0x40A0, ';',
|
|
0x4060, 'n', // not
|
|
0x2820, 'x', // what?
|
|
0x2420, ',',
|
|
0x2220, '%', // ( in 026 Fortran
|
|
0x2120, '_',
|
|
0x20A0, '>',
|
|
0x2060, '>',
|
|
};
|
|
|
|
int hollerith_to_ascii (unsigned short h)
|
|
{
|
|
int i;
|
|
|
|
h &= 0xFFF0;
|
|
|
|
for (i = 0; i < sizeof(cardcode_029) / sizeof(CPCODE); i++)
|
|
if (cardcode_029[i].hollerith == h)
|
|
return cardcode_029[i].ascii;
|
|
|
|
return '?';
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------------
|
|
// trim - remove trailing whitespace from string s
|
|
// ---------------------------------------------------------------------------------
|
|
|
|
void trim (char *s)
|
|
{
|
|
char *nb;
|
|
|
|
for (nb = s-1; *s; s++)
|
|
if (*s > ' ')
|
|
nb = s;
|
|
|
|
nb[1] = '\0';
|
|
}
|
|
|
|
int ascii_to_ebcdic_table[128] =
|
|
{
|
|
0x00,0x01,0x02,0x03,0x37,0x2d,0x2e,0x2f, 0x16,0x05,0x25,0x0b,0x0c,0x0d,0x0e,0x0f,
|
|
0x10,0x11,0x12,0x13,0x3c,0x3d,0x32,0x26, 0x18,0x19,0x3f,0x27,0x1c,0x1d,0x1e,0x1f,
|
|
0x40,0x5a,0x7f,0x7b,0x5b,0x6c,0x50,0x7d, 0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x4b,0x61,
|
|
0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7, 0xf8,0xf9,0x7a,0x5e,0x4c,0x7e,0x6e,0x6f,
|
|
|
|
0x7c,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, 0xc8,0xc9,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,
|
|
0xd7,0xd8,0xd9,0xe2,0xe3,0xe4,0xe5,0xe6, 0xe7,0xe8,0xe9,0xba,0xe0,0xbb,0xb0,0x6d,
|
|
0x79,0x81,0x82,0x83,0x84,0x85,0x86,0x87, 0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96,
|
|
0x97,0x98,0x99,0xa2,0xa3,0xa4,0xa5,0xa6, 0xa7,0xa8,0xa9,0xc0,0x4f,0xd0,0xa1,0x07,
|
|
};
|
|
|
|
char *getname (unsigned short *ptr)
|
|
{
|
|
static char str[6];
|
|
int i, j, ch;
|
|
long v;
|
|
|
|
v = (ptr[0] << 16L) | ptr[1];
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
ch = ((v >> 24) & 0x3F) | 0xC0; // recover those lost two bits
|
|
v <<= 6;
|
|
|
|
str[i] = ' ';
|
|
|
|
for (j = 0; j < (sizeof(ascii_to_ebcdic_table)/sizeof(ascii_to_ebcdic_table[0])); j++) {
|
|
if (ascii_to_ebcdic_table[j] == ch) {
|
|
str[i] = j;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
str[5] = '\0';
|
|
return str;
|
|
}
|
|
|