mirror of
https://github.com/simh/simh.git
synced 2026-01-27 04:22:24 +00:00
Notes For V3.2-1
RESTRICTION: The PDP-15 FPP is only partially debugged. Do NOT enable this feature for normal operations. 1. New Features in 3.2-1 1.1 SCP and libraries - Added SET CONSOLE subhierarchy. - Added SHOW CONSOLE subhierarchy. - Added limited keyboard mapping capability. 1.2 HP2100 (new features from Dave Bryan) - Added instruction printout to HALT message. - Added M and T internal registers. - Added N, S, and U breakpoints. 1.3 PDP-11 and VAX - Added DHQ11 support (from John Dundas) 2. Bugs Fixed in 3.2-1 2.1 HP2100 (most fixes from Dave Bryan) - SBT increments B after store. - DMS console map must check dms_enb. - SFS x,C and SFC x,C work. - MP violation clears automatically on interrupt. - SFS/SFC 5 is not gated by protection enabled. - DMS enable does not disable mem prot checks. - DMS status inconsistent at simulator halt. - Examine/deposit are checking wrong addresses. - Physical addresses are 20b not 15b. - Revised DMS to use memory rather than internal format. - Revised IBL facility to conform to microcode. - Added DMA EDT I/O pseudo-opcode. - Separated DMA SRQ (service request) from FLG. - Revised peripherals to make SFS x,C and SFC x,C work. - Revised boot ROMs to use IBL facility. - Revised IBL treatment of SR to preserve SR<5:3>. - Fixed LPS, LPT timing. - Fixed DP boot interpretation of SR<0>. - Revised DR boot code to use IBL algorithm. - Fixed TTY input behavior during typeout for RTE-IV. - Suppressed nulls on TTY output for RTE-IV. - Added SFS x,C and SFC x,C to print/parse routines. - Fixed spurious timing error in magtape reads. 2.2 All DEC console devices - Removed SET TTI CTRL-C option. 2.3 PDP-11/VAX peripherals - Fixed bug in TQ reporting write protect status (reported by Lyle Bickley). - Fixed TK70 model number and media ID (found by Robert Schaffrath). - Fixed bug in autoconfigure (found by John Dundas). 2.4 VAX - Fixed bug in DIVBx and DIVWx (reported by Peter Trimmel).
This commit is contained in:
committed by
Mark Pizzolato
parent
26aa6de663
commit
e2ba672610
4503
Ibm1130/utils/asm1130.c
Normal file
4503
Ibm1130/utils/asm1130.c
Normal file
File diff suppressed because it is too large
Load Diff
175
Ibm1130/utils/asm1130.mak
Normal file
175
Ibm1130/utils/asm1130.mak
Normal file
@@ -0,0 +1,175 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "asm1130.mak" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/asm1130.exe $(OUTDIR)/asm1130.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"asm1130.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"asm1130.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/asm1130.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/asm1130.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console\
|
||||
/INCREMENTAL:no /PDB:$(OUTDIR)/"asm1130.pdb" /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"asm1130.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/asm1130.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/asm1130.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/asm1130.exe $(OUTDIR)/asm1130.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"asm1130.pch" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"asm1130.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"asm1130.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/asm1130.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/asm1130.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console\
|
||||
/INCREMENTAL:yes /PDB:$(OUTDIR)/"asm1130.pdb" /DEBUG /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"asm1130.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/asm1130.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/asm1130.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\asm1130.c
|
||||
|
||||
$(INTDIR)/asm1130.obj : $(SOURCE) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util_io.c
|
||||
DEP_UTIL_=\
|
||||
.\util_io.h
|
||||
|
||||
$(INTDIR)/util_io.obj : $(SOURCE) $(DEP_UTIL_) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
755
Ibm1130/utils/bindump.c
Normal file
755
Ibm1130/utils/bindump.c
Normal file
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
* (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
|
||||
|
||||
#include "util_io.h"
|
||||
|
||||
#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 (fxread(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
|
||||
fxwrite(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 (fxread(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 (fxread(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;
|
||||
}
|
||||
|
||||
|
||||
175
Ibm1130/utils/bindump.mak
Normal file
175
Ibm1130/utils/bindump.mak
Normal file
@@ -0,0 +1,175 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "bindump.mak" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/bindump.exe $(OUTDIR)/bindump.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"bindump.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"bindump.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/bindump.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/bindump.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
/NOLOGO /SUBSYSTEM:console /INCREMENTAL:no /PDB:$(OUTDIR)/"bindump.pdb"\
|
||||
/MACHINE:I386 /OUT:$(OUTDIR)/"bindump.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/bindump.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/bindump.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/bindump.exe $(OUTDIR)/bindump.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"bindump.pch" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"bindump.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"bindump.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/bindump.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/bindump.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
/NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes /PDB:$(OUTDIR)/"bindump.pdb" /DEBUG\
|
||||
/MACHINE:I386 /OUT:$(OUTDIR)/"bindump.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/bindump.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/bindump.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bindump.c
|
||||
|
||||
$(INTDIR)/bindump.obj : $(SOURCE) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util_io.c
|
||||
DEP_UTIL_=\
|
||||
.\util_io.h
|
||||
|
||||
$(INTDIR)/util_io.obj : $(SOURCE) $(DEP_UTIL_) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
262
Ibm1130/utils/checkdisk.c
Normal file
262
Ibm1130/utils/checkdisk.c
Normal file
@@ -0,0 +1,262 @@
|
||||
/*
|
||||
* (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
|
||||
*/
|
||||
|
||||
// checkdisk - validates and optionally dumps an IBM1130 DMS2 disk image file
|
||||
//
|
||||
// Usage:
|
||||
// checkdisk [-f] [-d cyl.sec|abssec] [-n count] filename
|
||||
//
|
||||
// Examples:
|
||||
// checkdisk file.dsk
|
||||
// report any misnumbered sectors in file.dsk
|
||||
//
|
||||
// checkdisk -f file.dsk
|
||||
// report and fix any misnumbered sectors
|
||||
//
|
||||
// checkdisk -d 198.0 file.dsk
|
||||
// dump cylinder 198 sector 0
|
||||
//
|
||||
// checkdisk -d 0 file.dsk
|
||||
// dump absolute sector 0
|
||||
//
|
||||
// checkdisk -d 198.0 -n 4 file.dsk
|
||||
// dump 4 sectors starting at m.n
|
||||
// -----------------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "util_io.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <io.h>
|
||||
#else
|
||||
long filelength (int fno);
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define BOOL int
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
#define DSK_NUMWD 321 /* words/sector */
|
||||
#define DSK_NUMSC 4 /* sectors/surface */
|
||||
#define DSK_NUMSF 2 /* surfaces/cylinder */
|
||||
#define DSK_NUMCY 203 /* cylinders/drive */
|
||||
#define DSK_NUMDR 5 /* drives/controller */
|
||||
#define DSK_SIZE (DSK_NUMCY * DSK_NUMSF * DSK_NUMSC * DSK_NUMWD) /* words/drive */
|
||||
|
||||
char *usestr = "Usage: checkdisk [-f] [-d cyl.sec|abssec] [-n count] diskfile";
|
||||
char *baddisk = "Cannot fix this";
|
||||
|
||||
void bail (char *msg);
|
||||
char *lowcase (char *str);
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
char *fname = NULL, *arg, *argval;
|
||||
int i, j, cyl, sec, pos, asec, retry, nbad = 0, nfixed = 0, nline;
|
||||
BOOL fixit = FALSE, dump = FALSE;
|
||||
int dsec, nsec = 1;
|
||||
unsigned short wd, buf[DSK_NUMWD];
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
arg = argv[i++];
|
||||
if (*arg == '-') {
|
||||
arg++;
|
||||
lowcase(arg);
|
||||
while (*arg) {
|
||||
switch (*arg++) {
|
||||
case 'f':
|
||||
fixit = TRUE;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
dump = TRUE;
|
||||
|
||||
if (i >= argc)
|
||||
bail(usestr);
|
||||
|
||||
argval = argv[i++];
|
||||
if (strchr(argval, '.') != NULL) {
|
||||
if (sscanf(argval, "%d.%d", &cyl, &sec) != 2)
|
||||
bail(usestr);
|
||||
|
||||
dsec = cyl*(DSK_NUMSF*DSK_NUMSC) + sec;
|
||||
}
|
||||
else if (sscanf(argval, "%d", &dsec) != 1)
|
||||
bail(usestr);
|
||||
|
||||
if (dsec < 0 || dsec >= (DSK_NUMCY*DSK_NUMSF*DSK_NUMSC))
|
||||
bail("No such sector");
|
||||
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (i >= argc)
|
||||
bail(usestr);
|
||||
|
||||
argval = argv[i++];
|
||||
if (sscanf(argval, "%d", &nsec) != 1)
|
||||
bail(usestr);
|
||||
|
||||
if (nsec <= 0)
|
||||
bail(usestr);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
bail(usestr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fname == NULL)
|
||||
fname = arg;
|
||||
else
|
||||
bail(usestr);
|
||||
}
|
||||
|
||||
if (fname == NULL)
|
||||
bail(usestr);
|
||||
|
||||
if ((fp = fopen(fname, "rb+")) == NULL) {
|
||||
perror(fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (filelength(fileno(fp)) != 2*DSK_SIZE) {
|
||||
fprintf(stderr, "File is wrong length, expected %d\n", DSK_SIZE);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
for (cyl = 0; cyl < DSK_NUMCY; cyl++) {
|
||||
for (sec = 0; sec < (DSK_NUMSF*DSK_NUMSC); sec++) {
|
||||
retry = 1;
|
||||
again:
|
||||
asec = cyl*(DSK_NUMSF*DSK_NUMSC) + sec;
|
||||
pos = asec*2*DSK_NUMWD;
|
||||
|
||||
if (fseek(fp, pos, SEEK_SET) != 0) {
|
||||
fprintf(stderr, "Error seeking to pos %x\n", pos);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
if (fxread(&wd, sizeof(wd), 1, fp) != 1) {
|
||||
fprintf(stderr, "Error reading word at abs sec %x, cyl %x, sec %x at offset %x\n", asec, cyl, sec, pos);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
if (wd != asec) {
|
||||
fprintf(stderr, "Bad sector #%x at abs sec %x, cyl %x, sec %x at offset %x\n", wd, asec, cyl, sec, pos);
|
||||
nbad++;
|
||||
|
||||
if (fixit) {
|
||||
if (fseek(fp, pos, SEEK_SET) != 0) {
|
||||
fprintf(stderr, "Error seeking to pos %x\n", pos);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
if (fxwrite(&asec, sizeof(wd), 1, fp) != 1) {
|
||||
fprintf(stderr, "Error writing sector # to abs sec %x, cyl %x, sec %x at offset %x\n", asec, cyl, sec, pos);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
if (retry) {
|
||||
retry = 0;
|
||||
nfixed++;
|
||||
goto again;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Failed after retry\n");
|
||||
bail(baddisk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nbad)
|
||||
printf("%d bad sector mark%s %s\n", nbad, (nbad == 1) ? "" : "s", fixit ? "fixed" : "found");
|
||||
else if (! dump)
|
||||
printf("All sector marks OK\n");
|
||||
|
||||
if (! dump)
|
||||
return 0;
|
||||
|
||||
pos = dsec*2*DSK_NUMWD;
|
||||
if (fseek(fp, pos, SEEK_SET) != 0) {
|
||||
fprintf(stderr, "Error seeking to pos %x\n", pos);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
for (i = 0; i < nsec; i++) {
|
||||
cyl = dsec / (DSK_NUMSF*DSK_NUMSC);
|
||||
sec = dsec - cyl*(DSK_NUMSF*DSK_NUMSC);
|
||||
|
||||
if (fxread(&buf, sizeof(buf[0]), DSK_NUMWD, fp) != DSK_NUMWD) {
|
||||
fprintf(stderr, "Error reading abs sec %x, cyl %x, sec %x at offset %x\n", dsec, cyl, sec, pos);
|
||||
bail(baddisk);
|
||||
}
|
||||
|
||||
printf("\nSector %d.%d - %d - /%04x label %04x\n", cyl, sec, dsec, dsec, buf[0]);
|
||||
for (nline = 0, j = 1; j < DSK_NUMWD; j++) {
|
||||
printf("%04x", buf[j]);
|
||||
if (++nline == 16) {
|
||||
putchar('\n');
|
||||
nline = 0;
|
||||
}
|
||||
else
|
||||
putchar(' ');
|
||||
}
|
||||
|
||||
dsec++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bail (char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* lowcase - force a string to lower case (ASCII)
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
char *lowcase (char *str)
|
||||
{
|
||||
char *s;
|
||||
|
||||
for (s = str; *s; s++) {
|
||||
if (*s >= 'A' && *s <= 'Z')
|
||||
*s += 32;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
long filelength (int fno)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if (fstat(fno, &sb) != 0)
|
||||
return 0;
|
||||
|
||||
return (long) sb.st_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
177
Ibm1130/utils/checkdisk.mak
Normal file
177
Ibm1130/utils/checkdisk.mak
Normal file
@@ -0,0 +1,177 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "checkdisk.mak" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Release"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/checkdisk.exe $(OUTDIR)/checkdisk.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"checkdisk.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"checkdisk.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/checkdisk.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/checkdisk.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib /NOLOGO\
|
||||
/SUBSYSTEM:console /INCREMENTAL:no /PDB:$(OUTDIR)/"checkdisk.pdb" /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"checkdisk.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/checkdisk.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/checkdisk.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/checkdisk.exe $(OUTDIR)/checkdisk.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"checkdisk.pch" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"checkdisk.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"checkdisk.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/checkdisk.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/checkdisk.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib /NOLOGO\
|
||||
/SUBSYSTEM:console /INCREMENTAL:yes /PDB:$(OUTDIR)/"checkdisk.pdb" /DEBUG\
|
||||
/MACHINE:I386 /OUT:$(OUTDIR)/"checkdisk.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/checkdisk.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/checkdisk.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\checkdisk.c
|
||||
DEP_CHECK=\
|
||||
.\util_io.h\
|
||||
\MSVC20\INCLUDE\sys\types.h\
|
||||
\MSVC20\INCLUDE\sys\stat.h
|
||||
|
||||
$(INTDIR)/checkdisk.obj : $(SOURCE) $(DEP_CHECK) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util_io.c
|
||||
|
||||
$(INTDIR)/util_io.obj : $(SOURCE) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
612
Ibm1130/utils/diskview.c
Normal file
612
Ibm1130/utils/diskview.c
Normal file
@@ -0,0 +1,612 @@
|
||||
/*
|
||||
* (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
|
||||
*/
|
||||
|
||||
// DISKVIEW - lists contents of an 1130 system disk image file. Not finished yet.
|
||||
// needs LET/SLET listing routine.
|
||||
//
|
||||
// usage:
|
||||
// diskview -v diskfile
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "util_io.h"
|
||||
|
||||
#define BETWEEN(v,a,b) (((v) >= (a)) && ((v) <= (b)))
|
||||
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
|
||||
#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
# define BOOL int
|
||||
#endif
|
||||
|
||||
#define NOT_DEF 0x0658 // defective cylinder table entry means no defect
|
||||
|
||||
#define DSK_NUMWD 321 /* words/sector */
|
||||
#define DSK_NUMCY 203 /* cylinders/drive */
|
||||
#define DSK_SECCYL 8 /* sectors per cylinder */
|
||||
#define SECLEN 320 /* data words per sector */
|
||||
#define SLETLEN ((3*SECLEN)/4) /* length of slet in records */
|
||||
|
||||
typedef unsigned short WORD;
|
||||
|
||||
FILE *fp;
|
||||
WORD buf[DSK_NUMWD];
|
||||
WORD dcom[DSK_NUMWD];
|
||||
|
||||
#pragma pack(2)
|
||||
struct tag_slet {
|
||||
WORD phid;
|
||||
WORD addr;
|
||||
WORD nwords;
|
||||
WORD sector;
|
||||
} slet[SLETLEN];
|
||||
|
||||
#pragma pack()
|
||||
|
||||
WORD dcyl[3];
|
||||
BOOL verbose = FALSE;
|
||||
|
||||
void checksectors (void);
|
||||
void dump_id (void);
|
||||
void dump_dcom (void);
|
||||
void dump_resmon (void);
|
||||
void dump_slet (void);
|
||||
void dump_hdng (void);
|
||||
void dump_scra (void);
|
||||
void dump_let (void);
|
||||
void dump_flet (void);
|
||||
void dump_cib (void);
|
||||
void getsector (int sec, WORD *sbuf);
|
||||
void getdcyl (void);
|
||||
char *lowcase (char *str);
|
||||
|
||||
void bail(char *fmt, ...);
|
||||
char *trim (char *s);
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char *fname = NULL, *arg;
|
||||
static char usestr[] = "Usage: diskview [-v] filename";
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc;) {
|
||||
arg = argv[i++];
|
||||
if (*arg == '-') {
|
||||
arg++;
|
||||
lowcase(arg);
|
||||
while (*arg) {
|
||||
switch (*arg++) {
|
||||
case 'v':
|
||||
verbose = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
bail(usestr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fname == NULL)
|
||||
fname = arg;
|
||||
else
|
||||
bail(usestr);
|
||||
}
|
||||
|
||||
if (fname == NULL)
|
||||
bail(usestr);
|
||||
|
||||
if ((fp = fopen(fname, "rb")) == NULL) {
|
||||
perror(fname);
|
||||
return 2;
|
||||
}
|
||||
|
||||
printf("%s:\n", fname);
|
||||
|
||||
checksectors();
|
||||
getdcyl();
|
||||
|
||||
dump_id(); // ID & coldstart
|
||||
dump_dcom(); // DCOM
|
||||
dump_resmon(); // resident image
|
||||
dump_slet(); // SLET
|
||||
dump_hdng(); // heading sector
|
||||
dump_scra();
|
||||
dump_flet();
|
||||
dump_cib();
|
||||
dump_let();
|
||||
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// checksectors - verify that all sectors are properly numbered
|
||||
|
||||
void checksectors ()
|
||||
{
|
||||
WORD sec = 0;
|
||||
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
for (sec = 0; sec < DSK_NUMCY*DSK_SECCYL; sec++) {
|
||||
if (fxread(buf, sizeof(WORD), DSK_NUMWD, fp) != DSK_NUMWD)
|
||||
bail("File read error or not a disk image file");
|
||||
|
||||
if (buf[0] != sec)
|
||||
bail("Sector /%x is misnumbered, run checkdisk [-f]", sec);
|
||||
}
|
||||
}
|
||||
|
||||
// get defective cylinder list
|
||||
|
||||
void getdcyl (void)
|
||||
{
|
||||
fseek(fp, sizeof(WORD), SEEK_SET); // skip sector count
|
||||
if (fxread(dcyl, sizeof(WORD), 3, fp) != 3)
|
||||
bail("Unable to read defective cylinder table");
|
||||
}
|
||||
|
||||
// getsector - read specified absolute sector
|
||||
|
||||
void getsector (int sec, WORD *sbuf)
|
||||
{
|
||||
int i, cyl, ssec;
|
||||
|
||||
sec &= 0x7FF; // mask of drive bits, if any
|
||||
|
||||
cyl = sec / DSK_SECCYL; // get cylinder
|
||||
ssec = sec & ~(DSK_SECCYL-1); // mask to get starting sector of cylinder
|
||||
for (i = 0; i < 3; i++) { // map through defective cylinder table
|
||||
if (dcyl[i] == ssec) {
|
||||
sec &= (DSK_SECCYL-1); // mask to get base sector
|
||||
cyl = DSK_NUMCY-3+i; // replacements are last three on disk
|
||||
sec += cyl*DSK_SECCYL; // add new cylinder offset
|
||||
break;
|
||||
}
|
||||
}
|
||||
// read the sector
|
||||
if (fseek(fp, (sec*DSK_NUMWD+1)*sizeof(WORD), SEEK_SET) != 0)
|
||||
bail("File seek failed");
|
||||
|
||||
if (fxread(sbuf, sizeof(WORD), DSK_NUMWD, fp) != DSK_NUMWD)
|
||||
bail("File read error or not a disk image file");
|
||||
}
|
||||
|
||||
void dump (int nwords)
|
||||
{
|
||||
int i, nline = 0;
|
||||
|
||||
for (i = 0; i < nwords; i++) {
|
||||
if (nline == 16) {
|
||||
putchar('\n');
|
||||
nline = 0;
|
||||
}
|
||||
|
||||
printf("%04x", buf[i]);
|
||||
nline++;
|
||||
}
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void showmajor (char *label)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\n--- %s ", label);
|
||||
|
||||
for (i = strlen(label); i < 40; i++)
|
||||
putchar('-');
|
||||
|
||||
putchar('\n');
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void name (char *label)
|
||||
{
|
||||
printf("%-32.32s ", label);
|
||||
}
|
||||
|
||||
void pbf (char *label, WORD *buf, int nwords)
|
||||
{
|
||||
int i, nout;
|
||||
|
||||
name(label);
|
||||
|
||||
for (i = nout = 0; i < nwords; i++, nout++) {
|
||||
if (nout == 8) {
|
||||
putchar('\n');
|
||||
name("");
|
||||
nout = 0;
|
||||
}
|
||||
printf(" %04x", buf[i]);
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void prt (char *label, char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
name(label);
|
||||
|
||||
putchar(' ');
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
va_end(args);
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void dump_id (void)
|
||||
{
|
||||
showmajor("Sector 0 - ID & coldstart");
|
||||
getsector(0, buf);
|
||||
|
||||
pbf("DCYL def cyl table", buf+ 0, 3);
|
||||
pbf("CIDN cart id", buf+ 3, 1);
|
||||
pbf(" copy code", buf+ 4, 1);
|
||||
pbf("DTYP disk type", buf+ 7, 1);
|
||||
pbf(" diskz copy", buf+ 30, 8);
|
||||
pbf(" cold start pgm",buf+270, 8);
|
||||
}
|
||||
|
||||
// EQUIVALENCES FOR DCOM PARAMETERS
|
||||
#define NAME 4 // NAME OF PROGRAM/CORE LOAD
|
||||
#define DBCT 6 // BLOCK CT OF PROGRAM/CORE LOAD
|
||||
#define FCNT 7 // FILES SWITCH
|
||||
#define SYSC 8 // SYSTEM/NON-SYSTEM CARTRIDGE INDR
|
||||
#define JBSW 9 // JOBT SWITCH
|
||||
#define CBSW 10 // CLB-RETURN SWITCH
|
||||
#define LCNT 11 // NO. OF LOCALS
|
||||
#define MPSW 12 // CORE MAP SWITCH
|
||||
#define MDF1 13 // NO. DUP CTRL RECORDS (MODIF)
|
||||
#define MDF2 14 // ADDR OF MODIF BUFFER
|
||||
#define NCNT 15 // NO. OF NOCALS
|
||||
#define ENTY 16 // RLTV ENTRY ADDR OF PROGRAM
|
||||
#define RP67 17 // 1442-5 SWITCH
|
||||
#define TODR 18 // OBJECT WORK STORAGE DRIVE CODE
|
||||
#define FHOL 20 // ADDR LARGEST HOLE IN FIXED AREA
|
||||
#define FSZE 21 // BLK CNT LARGEST HOLE IN FXA
|
||||
#define UHOL 22 // ADDR LAST HOLE IN USER AREA 2-10
|
||||
#define USZE 23 // BLK CNT LAST HOLE IN UA 2-10
|
||||
#define DCSW 24 // DUP CALL SWITCH
|
||||
#define PIOD 25 // PRINCIPAL I/O DEVICE INDICATOR
|
||||
#define PPTR 26 // PRINCIPAL PRINT DEVICE INDICATOR
|
||||
#define CIAD 27 // RLTV ADDR IN @STRT OF CIL ADDR
|
||||
#define ACIN 28 // AVAILABLE CARTRIDGE INDICATOR
|
||||
#define GRPH 29 // 2250 INDICATOR 2G2
|
||||
#define GCNT 30 // NO. G2250 RECORDS 2G2
|
||||
#define LOSW 31 // LOCAL-CALLS-LOCAL SWITCH 2-2
|
||||
#define X3SW 32 // SPECIAL ILS SWITCH 2-2
|
||||
#define ECNT 33 // NO. OF *EQUAT RCDS 2-4
|
||||
#define ANDU 35 // 1+BLK ADDR END OF UA (ADJUSTED)
|
||||
#define BNDU 40 // 1+BLK ADDR END OF UA (BASE)
|
||||
#define FPAD 45 // FILE PROTECT ADDR
|
||||
#define PCID 50 // CARTRIDGE ID, PHYSICAL DRIVE
|
||||
#define CIDN 55 // CARTRIDGE ID, LOGICAL DRIVE
|
||||
#define CIBA 60 // SCTR ADDR OF CIB
|
||||
#define SCRA 65 // SCTR ADDR OF SCRA
|
||||
#define FMAT 70 // FORMAT OF PROG IN WORKING STG
|
||||
#define FLET 75 // SCTR ADDR 1ST SCTR OF FLET
|
||||
#define ULET 80 // SCTR ADDR 1ST SCTR OF LET
|
||||
#define WSCT 85 // BLK CNT OF PROG IN WORKING STG
|
||||
#define CSHN 90 // NO. SCTRS IN CUSHION AREA
|
||||
|
||||
struct tag_dcominfo {
|
||||
char *nm;
|
||||
int offset;
|
||||
char *descr;
|
||||
} dcominfo[] = {
|
||||
"NAME", 4, "NAME OF PROGRAM/CORE LOAD",
|
||||
"DBCT", 6, "BLOCK CT OF PROGRAM/CORE LOAD",
|
||||
"FCNT", 7, "FILES SWITCH",
|
||||
"SYSC", 8, "SYSTEM/NON-SYSTEM CARTRIDGE INDR",
|
||||
"JBSW", 9, "JOBT SWITCH",
|
||||
"CBSW", 10, "CLB-RETURN SWITCH",
|
||||
"LCNT", 11, "NO. OF LOCALS",
|
||||
"MPSW", 12, "CORE MAP SWITCH",
|
||||
"MDF1", 13, "NO. DUP CTRL RECORDS (MODIF)",
|
||||
"MDF2", 14, "ADDR OF MODIF BUFFER",
|
||||
"NCNT", 15, "NO. OF NOCALS",
|
||||
"ENTY", 16, "RLTV ENTRY ADDR OF PROGRAM",
|
||||
"RP67", 17, "1442-5 SWITCH",
|
||||
"TODR", 18, "OBJECT WORK STORAGE DRIVE CODE",
|
||||
"FHOL", 20, "ADDR LARGEST HOLE IN FIXED AREA",
|
||||
"FSZE", 21, "BLK CNT LARGEST HOLE IN FXA",
|
||||
"UHOL", 22, "ADDR LAST HOLE IN USER AREA",
|
||||
"USZE", 23, "BLK CNT LAST HOLE IN UA",
|
||||
"DCSW", 24, "DUP CALL SWITCH",
|
||||
"PIOD", 25, "PRINCIPAL I/O DEVICE INDICATOR",
|
||||
"PPTR", 26, "PRINCIPAL PRINT DEVICE INDICATOR",
|
||||
"CIAD", 27, "RLTV ADDR IN @STRT OF CIL ADDR",
|
||||
"ACIN", 28, "AVAILABLE CARTRIDGE INDICATOR",
|
||||
"GRPH", 29, "2250 INDICATOR",
|
||||
"GCNT", 30, "NO. G2250 RECORDS",
|
||||
"LOSW", 31, "LOCAL-CALLS-LOCAL SWITCH",
|
||||
"X3SW", 32, "SPECIAL ILS SWITCH",
|
||||
"ECNT", 33, "NO. OF *EQUAT RCDS",
|
||||
"ANDU", 35, "1+BLK ADDR END OF UA (ADJUSTED)",
|
||||
"BNDU", 40, "1+BLK ADDR END OF UA (BASE)",
|
||||
"FPAD", 45, "FILE PROTECT ADDR",
|
||||
"PCID", 50, "CARTRIDGE ID, PHYSICAL DRIVE",
|
||||
"CIDN", 55, "CARTRIDGE ID, LOGICAL DRIVE",
|
||||
"CIBA", 60, "SCTR ADDR OF CIB",
|
||||
"SCRA", 65, "SCTR ADDR OF SCRA",
|
||||
"FMAT", 70, "FORMAT OF PROG IN WORKING STG",
|
||||
"FLET", 75, "SCTR ADDR 1ST SCTR OF FLET",
|
||||
"ULET", 80, "SCTR ADDR 1ST SCTR OF LET",
|
||||
"WSCT", 85, "BLK CNT OF PROG IN WORKING STG",
|
||||
"CSHN", 90, "NO. SCTRS IN CUSHION AREA",
|
||||
NULL
|
||||
};
|
||||
|
||||
void dump_dcom (void)
|
||||
{
|
||||
struct tag_dcominfo *d;
|
||||
char txt[50];
|
||||
|
||||
showmajor("Sector 1 - DCOM");
|
||||
getsector(1, dcom);
|
||||
|
||||
for (d = dcominfo; d->nm != NULL; d++) {
|
||||
sprintf(txt, "%-4.4s %s", d->nm, d->descr);
|
||||
pbf(txt, dcom+d->offset, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void dump_resmon (void)
|
||||
{
|
||||
showmajor("Sector 2 - Resident Image");
|
||||
getsector(2, buf);
|
||||
dump(verbose ? SECLEN : 32);
|
||||
}
|
||||
|
||||
struct {
|
||||
int pfrom, pto;
|
||||
int printed;
|
||||
char *name;
|
||||
} sletinfo[] = {
|
||||
0x01, 0x12, FALSE, "DUP",
|
||||
0x1F, 0x39, FALSE, "Fortran",
|
||||
0x51, 0x5C, FALSE, "Cobol",
|
||||
0x6E, 0x74, FALSE, "Supervisor",
|
||||
0x78, 0x84, FALSE, "Core Load Builder",
|
||||
0x8C, 0x8C, FALSE, "Sys 1403 prt",
|
||||
0x8D, 0x8D, FALSE, "Sys 1132 prt",
|
||||
0x8E, 0x8E, FALSE, "Sys console prt",
|
||||
0x8F, 0x8F, FALSE, "Sys 2501 rdr",
|
||||
0x90, 0x90, FALSE, "Sys 1442 rdr/pun",
|
||||
0x91, 0x91, FALSE, "Sys 1134 paper tape",
|
||||
0x92, 0x92, FALSE, "Sys kbd",
|
||||
0x93, 0x93, FALSE, "Sys 2501/1442 conv",
|
||||
0x94, 0x94, FALSE, "Sys 1134 conv",
|
||||
0x95, 0x95, FALSE, "Sys kbd conv",
|
||||
0x96, 0x96, FALSE, "Sys diskz",
|
||||
0x97, 0x97, FALSE, "Sys disk1",
|
||||
0x98, 0x98, FALSE, "Sys diskn",
|
||||
0x99, 0x99, FALSE, "(primary print)",
|
||||
0x9A, 0x9A, FALSE, "(primary input)",
|
||||
0x9B, 0x9B, FALSE, "(primary input excl kbd)",
|
||||
0x9C, 0x9C, FALSE, "(primary sys conv)",
|
||||
0x9D, 0x9D, FALSE, "(primary conv excl kbd)",
|
||||
0xA0, 0xA1, FALSE, "Core Image Loader",
|
||||
0xB0, 0xCC, FALSE, "RPG",
|
||||
0xCD, 0xCE, FALSE, "Dup Part 2",
|
||||
0xCF, 0xF6, FALSE, "Macro Assembler",
|
||||
0
|
||||
};
|
||||
|
||||
void dump_slet (void)
|
||||
{
|
||||
int i, j, iphase, nsecs, sec, max_sec = 0;
|
||||
char sstr[16], *smark;
|
||||
|
||||
showmajor("Sectors 3-5 - SLET");
|
||||
for (i = 0; i < 3; i++) {
|
||||
getsector(3+i, buf);
|
||||
memmove(((WORD *) slet)+SECLEN*i, buf, SECLEN*sizeof(WORD));
|
||||
}
|
||||
|
||||
printf("# PHID Addr Len Sector Secs\n");
|
||||
printf("------------------------------------------\n");
|
||||
for (i = 0; i < SLETLEN; i++) {
|
||||
if (slet[i].phid == 0)
|
||||
break;
|
||||
|
||||
sec = slet[i].sector;
|
||||
iphase = (int) (signed short) slet[i].phid;
|
||||
nsecs = (slet[i].nwords + SECLEN-1)/SECLEN;
|
||||
|
||||
if (sec & 0xF800) {
|
||||
smark = "*";
|
||||
sec &= 0x7FF;
|
||||
}
|
||||
else
|
||||
smark = " ";
|
||||
|
||||
for (j = 0; sletinfo[j].pfrom != 0; j++)
|
||||
if (sletinfo[j].pfrom <= iphase && sletinfo[j].pto >= iphase)
|
||||
break;
|
||||
|
||||
sprintf(sstr, "(%d.%d)", sec / DSK_SECCYL, slet[i].sector % DSK_SECCYL);
|
||||
|
||||
printf("%3d %04x %4d %04x %04x %04x %s %-7s %3x",
|
||||
i, slet[i].phid, iphase, slet[i].addr, slet[i].nwords, slet[i].sector, smark, sstr, nsecs);
|
||||
|
||||
if (iphase < 0)
|
||||
iphase = -iphase;
|
||||
|
||||
if (sletinfo[j].pfrom == 0)
|
||||
printf(" ???");
|
||||
else if (! sletinfo[j].printed) {
|
||||
printf(" %s", sletinfo[j].name);
|
||||
sletinfo[j].printed = TRUE;
|
||||
}
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
if (sec == (slet[j].sector & 0x7FF)) {
|
||||
printf(" (same as %04x)", slet[j].phid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
max_sec = MAX(max_sec, sec+nsecs-1); // find last sector used
|
||||
|
||||
putchar('\n');
|
||||
|
||||
if (i >= 15 && ! verbose) {
|
||||
printf("...\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
int ebcdic_to_ascii (int ch)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 32; j < 128; j++)
|
||||
if (ascii_to_ebcdic_table[j] == ch)
|
||||
return j;
|
||||
|
||||
return '?';
|
||||
}
|
||||
|
||||
#define HDR_LEN 120
|
||||
|
||||
void dump_hdng(void)
|
||||
{
|
||||
int i;
|
||||
char str[HDR_LEN+1], *p = str;
|
||||
|
||||
showmajor("Sector 7 - Heading");
|
||||
getsector(7, buf);
|
||||
|
||||
for (i = 0; i < (HDR_LEN/2); i++) {
|
||||
*p++ = ebcdic_to_ascii((buf[i] >> 8) & 0xFF);
|
||||
*p++ = ebcdic_to_ascii( buf[i] & 0xFF);
|
||||
}
|
||||
|
||||
*p = '\0';
|
||||
trim(str);
|
||||
printf("%s\n", str);
|
||||
}
|
||||
|
||||
BOOL mget (int offset, char *name)
|
||||
{
|
||||
char title[80];
|
||||
|
||||
if (dcom[offset] == 0)
|
||||
return FALSE;
|
||||
|
||||
getsector(dcom[offset], buf);
|
||||
sprintf(title, "Sector %x - %s", dcom[offset], name);
|
||||
showmajor(title);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void dump_scra (void)
|
||||
{
|
||||
if (! mget(SCRA, "SCRA"))
|
||||
return;
|
||||
|
||||
dump(verbose ? SECLEN : 32);
|
||||
}
|
||||
|
||||
void dump_let (void)
|
||||
{
|
||||
if (! mget(ULET, "LET"))
|
||||
return;
|
||||
}
|
||||
|
||||
void dump_flet (void)
|
||||
{
|
||||
if (! mget(FLET, "FLET"))
|
||||
return;
|
||||
}
|
||||
|
||||
void dump_cib (void)
|
||||
{
|
||||
if (! mget(CIBA, "CIB"))
|
||||
return;
|
||||
|
||||
dump(verbose ? SECLEN : 32);
|
||||
}
|
||||
|
||||
#define LFHD 5 // WORD COUNT OF LET/FLET HEADER PMN09970
|
||||
#define LFEN 3 // NO OF WDS PER LET/FLET ENTRY PMN09980
|
||||
#define SCTN 0 // RLTY ADDR OF LET/FLET SCTR NO. PMN09990
|
||||
#define UAFX 1 // RLTV ADDR OF SCTR ADDR OF UA/FXA PMN10000
|
||||
#define WDSA 3 // RLTV ADDR OF WDS AVAIL IN SCTR PMN10010
|
||||
#define NEXT 4 // RLTV ADDR OF ADDR NEXT SCTR PMN10020
|
||||
#define LFNM 0 // RLTV ADDR OF LET/FLET ENTRY NAME PMN10030
|
||||
#define BLCT 2 // RLTV ADDR OF LET/FLET ENTRY DBCT PMN10040
|
||||
|
||||
void bail (char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
fprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
putchar('\n');
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// trim - remove trailing whitespace from string s
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
char *trim (char *s)
|
||||
{
|
||||
char *os = s, *nb;
|
||||
|
||||
for (nb = s-1; *s; s++)
|
||||
if (*s > ' ')
|
||||
nb = s;
|
||||
|
||||
nb[1] = '\0';
|
||||
return os;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* lowcase - force a string to lowercase (ASCII)
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
char *lowcase (char *str)
|
||||
{
|
||||
char *s;
|
||||
|
||||
for (s = str; *s; s++) {
|
||||
if (*s >= 'A' && *s <= 'Z')
|
||||
*s += 32;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
175
Ibm1130/utils/diskview.mak
Normal file
175
Ibm1130/utils/diskview.mak
Normal file
@@ -0,0 +1,175 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "diskview.mak" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/diskview.exe $(OUTDIR)/diskview.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"diskview.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"diskview.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/diskview.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/diskview.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console\
|
||||
/INCREMENTAL:no /PDB:$(OUTDIR)/"diskview.pdb" /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"diskview.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/diskview.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/diskview.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/diskview.exe $(OUTDIR)/diskview.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"diskview.pch" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"diskview.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"diskview.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/diskview.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/diskview.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console\
|
||||
/INCREMENTAL:yes /PDB:$(OUTDIR)/"diskview.pdb" /DEBUG /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"diskview.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/diskview.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/diskview.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diskview.c
|
||||
|
||||
$(INTDIR)/diskview.obj : $(SOURCE) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util_io.c
|
||||
DEP_UTIL_=\
|
||||
.\util_io.h
|
||||
|
||||
$(INTDIR)/util_io.obj : $(SOURCE) $(DEP_UTIL_) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
47
Ibm1130/utils/makefile
Normal file
47
Ibm1130/utils/makefile
Normal file
@@ -0,0 +1,47 @@
|
||||
# (This makefile is for operating systems other than Windows,
|
||||
# or compilers other than Microsoft's. For MS builds, use the
|
||||
# .mak files).
|
||||
#
|
||||
# CC Command
|
||||
#
|
||||
# Note: -O2 is sometimes broken in GCC when setjump/longjump is being
|
||||
# used. Try -O2 only with released simulators.
|
||||
#
|
||||
|
||||
CC = gcc -O0 -lm -I .
|
||||
#CC = gcc -O2 -g -lm -I .
|
||||
|
||||
BIN =
|
||||
|
||||
IOLIB_DEP = util_io.c util_io.h
|
||||
IOLIB_SRC = util_io.c
|
||||
|
||||
#
|
||||
# Build everything
|
||||
#
|
||||
|
||||
all : ${BIN}asm1130 ${BIN}bindump ${BIN}checkdisk \
|
||||
${BIN}diskview ${BIN}mkboot ${BIN}viewdeck
|
||||
|
||||
#
|
||||
# Individual builds
|
||||
#
|
||||
|
||||
${BIN}asm1130 : asm1130.c ${IOLIB_DEP}
|
||||
${CC} asm1130.c ${IOLIB_SRC} -o $@
|
||||
|
||||
${BIN}bindump : bindump.c ${IOLIB_DEP}
|
||||
${CC} bindump.c ${IOLIB_SRC} -o $@
|
||||
|
||||
${BIN}checkdisk : checkdisk.c ${IOLIB_DEP}
|
||||
${CC} checkdisk.c ${IOLIB_SRC} -o $@
|
||||
|
||||
${BIN}diskview : diskview.c ${IOLIB_DEP}
|
||||
${CC} diskview.c ${IOLIB_SRC} -o $@
|
||||
|
||||
${BIN}mkboot : mkboot.c ${IOLIB_DEP}
|
||||
${CC} mkboot.c ${IOLIB_SRC} -o $@
|
||||
|
||||
${BIN}viewdeck : viewdeck.c ${IOLIB_DEP}
|
||||
${CC} viewdeck.c ${IOLIB_SRC} -o $@
|
||||
|
||||
706
Ibm1130/utils/mkboot.c
Normal file
706
Ibm1130/utils/mkboot.c
Normal file
@@ -0,0 +1,706 @@
|
||||
/*
|
||||
* (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
|
||||
*/
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// MKBOOT - reads card loader format cards and produces an absolute core image that
|
||||
// can then be dumped out in 1130 IPL, 1800 IPL or Core Image loader formats.
|
||||
//
|
||||
// Usage: mkboot [-v] binfile outfile [1130|1800|core [loaddr [hiaddr [ident]]]]"
|
||||
//
|
||||
// Arguments:
|
||||
// binfile - name of assembler output file (card loader format, absolute output)
|
||||
// outfile - name of output file to create
|
||||
// mode - output mode, default is 1130 IPL format
|
||||
// loaddr - low address to dump. Default is lowest address loaded from binfile
|
||||
// hiaddr - high address to dump. Defult is highest address loaded from binfile
|
||||
// ident - ident string to write in last 8 columns. Omit when when writing an
|
||||
// 1130 IPL card that requires all 80 columns of data.
|
||||
//
|
||||
// Examples:
|
||||
// mkboot somefile.bin somefile.ipl 1130
|
||||
//
|
||||
// loads somefile.bin, writes object in 1130 IPL format to somefile.ipl
|
||||
// Up to 80 columns will be written depending on what the object actually uses
|
||||
//
|
||||
// mkboot somefile.bin somefile.ipl 1130 0 48 SOMEF
|
||||
//
|
||||
// loads somefile.bin. Writes 72 columns (hex 48), with ident columns 73-80 = SOMEF001
|
||||
//
|
||||
// mkboot somefile.bin somefile.dat core 0 0 SOMEF001
|
||||
//
|
||||
// loads somefile.bin and writes a core image format deck with ident SOMEF001, SOMEF002, etc
|
||||
//
|
||||
// For other examples of usage, see MKDMS.BAT
|
||||
//
|
||||
// 1.00 - 2002Apr18 - first release. Tested only under Win32. The core image
|
||||
// loader format is almost certainly wrong. Cannot handle
|
||||
// relocatable input decks, but it works well enough to
|
||||
// load DSYSLDR1 which is what we are after here.
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "util_io.h"
|
||||
|
||||
#ifndef TRUE
|
||||
#define BOOL int
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
int strnicmp (char *a, char *b, int n);
|
||||
int strcmpi (char *a, char *b);
|
||||
#endif
|
||||
|
||||
#define BETWEEN(v,a,b) (((v) >= (a)) && ((v) <= (b)))
|
||||
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
|
||||
#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
|
||||
|
||||
#define MAXADDR 4096
|
||||
|
||||
typedef enum {R_ABSOLUTE = 0, R_RELATIVE = 1, R_LIBF = 2, R_CALL = 3} RELOC;
|
||||
|
||||
typedef enum {B_1130, B_1800, B_CORE} BOOTMODE;
|
||||
|
||||
BOOL verbose = FALSE;
|
||||
char *infile = NULL, *outfile = NULL;
|
||||
BOOTMODE mode = B_1130;
|
||||
int addr_from = 0, addr_to = 79;
|
||||
int outcols = 0; // columns written in using card output
|
||||
int maxiplcols = 80;
|
||||
char cardid[9]; // characters used for IPL card ID
|
||||
int pta = 0;
|
||||
int load_low = 0x7FFFFFF;
|
||||
int load_high = 0;
|
||||
unsigned short mem[MAXADDR]; // small core!
|
||||
|
||||
// mkboot - load a binary object deck into core and dump requested bytes as a boot card
|
||||
|
||||
void bail (char *msg);
|
||||
void verify_checksum(unsigned short *card);
|
||||
char *upcase (char *str);
|
||||
void unpack (unsigned short *card, unsigned short *buf);
|
||||
void dump (char *fname);
|
||||
void loaddata (char *fname);
|
||||
void write_1130 (void);
|
||||
void write_1800 (void);
|
||||
void write_core (void);
|
||||
void flushcard(void);
|
||||
int ascii_to_hollerith (int ch);
|
||||
void corecard_init (void);
|
||||
void corecard_writecard (char *sbrk_text);
|
||||
void corecard_writedata (void);
|
||||
void corecard_flush (void);
|
||||
void corecard_setorg (int neworg);
|
||||
void corecard_writew (int word, RELOC relative);
|
||||
void corecard_endcard (void);
|
||||
|
||||
char *fname = NULL;
|
||||
FILE *fout;
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
char *arg;
|
||||
static char usestr[] = "Usage: mkboot [-v] binfile outfile [1130|1800|core [loaddr [hiaddr [ident]]]]";
|
||||
int i, ano = 0, ok;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
arg = argv[i];
|
||||
if (*arg == '-') {
|
||||
arg++;
|
||||
while (*arg) {
|
||||
switch (*arg++) {
|
||||
case 'v':
|
||||
verbose = TRUE;
|
||||
break;
|
||||
default:
|
||||
bail(usestr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (ano++) {
|
||||
case 0:
|
||||
infile = arg;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
outfile = arg;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (strcmp(arg, "1130") == 0) mode = B_1130;
|
||||
else if (strcmp(arg, "1800") == 0) mode = B_1800;
|
||||
else if (strcmpi(arg, "core") == 0) mode = B_CORE;
|
||||
else bail(usestr);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (strnicmp(arg, "0x", 2) == 0) ok = sscanf(arg+2, "%x", &addr_from);
|
||||
else if (arg[0] == '/') ok = sscanf(arg+1, "%x", &addr_from);
|
||||
else ok = sscanf(arg, "%d", &addr_from);
|
||||
if (ok != 1) bail(usestr);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (strnicmp(arg, "0x", 2) == 0) ok = sscanf(arg+2, "%x", &addr_to);
|
||||
else if (arg[0] == '/') ok = sscanf(arg+1, "%x", &addr_to);
|
||||
else ok = sscanf(arg, "%d", &addr_to);
|
||||
if (ok != 1) bail(usestr);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
strncpy(cardid, arg, 9);
|
||||
cardid[8] = '\0';
|
||||
upcase(cardid);
|
||||
break;
|
||||
|
||||
default:
|
||||
bail(usestr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*cardid == '\0')
|
||||
maxiplcols = (mode == B_1130) ? 80 : 72;
|
||||
else {
|
||||
while (strlen(cardid) < 8)
|
||||
strcat(cardid, "0");
|
||||
maxiplcols = 72;
|
||||
}
|
||||
|
||||
loaddata(infile);
|
||||
|
||||
if (mode == B_1800)
|
||||
write_1800();
|
||||
else if (mode == B_CORE)
|
||||
write_core();
|
||||
else
|
||||
write_1130();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void write_1130 (void)
|
||||
{
|
||||
int addr;
|
||||
unsigned short word;
|
||||
|
||||
if ((fout = fopen(outfile, "wb")) == NULL) {
|
||||
perror(outfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (addr = addr_from; addr <= addr_to; addr++) {
|
||||
if (outcols >= maxiplcols)
|
||||
flushcard();
|
||||
|
||||
word = mem[addr];
|
||||
|
||||
// if F or L bits are set, or if high 2 bits of displacement are unequal, it's bad
|
||||
if ((word & 0x0700) || ! (((word & 0x00C0) == 0) || ((word & 0x00C0) == 0x00C0)))
|
||||
printf("Warning: word %04x @ %04x may not IPL properly\n", word & 0xFFFF, addr);
|
||||
|
||||
word = ((word & 0xF800) >> 4) | (word & 0x7F); // convert to 1130 IPL format
|
||||
|
||||
putc((word & 0x000F) << 4, fout); // write the 12 bits in little-endian binary AABBCC00 as CC00 AABB
|
||||
putc((word & 0x0FF0) >> 4, fout);
|
||||
outcols++;
|
||||
}
|
||||
flushcard();
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void write_1800 (void)
|
||||
{
|
||||
int addr;
|
||||
unsigned short word;
|
||||
|
||||
if ((fout = fopen(outfile, "wb")) == NULL) {
|
||||
perror(outfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (addr = addr_from; addr <= addr_to; addr++) {
|
||||
word = mem[addr];
|
||||
|
||||
if (outcols >= maxiplcols)
|
||||
flushcard();
|
||||
|
||||
putc(0, fout);
|
||||
putc(word & 0xFF, fout); // write the low 8 bits in little-endian binary
|
||||
outcols++;
|
||||
|
||||
putc(0, fout);
|
||||
putc((word >> 8) & 0xFF, fout); // write the high 8 bits in little-endian binary
|
||||
outcols++;
|
||||
}
|
||||
flushcard();
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void write_core (void)
|
||||
{
|
||||
int addr;
|
||||
|
||||
if ((fout = fopen(outfile, "wb")) == NULL) {
|
||||
perror(outfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
addr_from = load_low;
|
||||
addr_to = load_high;
|
||||
|
||||
maxiplcols = 72;
|
||||
corecard_init();
|
||||
corecard_setorg(addr_from);
|
||||
|
||||
for (addr = addr_from; addr <= addr_to; addr++) {
|
||||
corecard_writew(mem[addr], 0);
|
||||
}
|
||||
|
||||
corecard_flush();
|
||||
corecard_endcard();
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void flushcard (void)
|
||||
{
|
||||
int i, hol, ndig;
|
||||
char fmt[20], newdig[20];
|
||||
|
||||
if (outcols <= 0)
|
||||
return; // nothing to flush
|
||||
|
||||
while (outcols < maxiplcols) { // pad to required number of columns with blanks (no punches)
|
||||
putc(0, fout);
|
||||
putc(0, fout);
|
||||
outcols++;
|
||||
}
|
||||
|
||||
if (*cardid) { // add label
|
||||
for (i = 0; i < 8; i++) { // write label as specified
|
||||
hol = ascii_to_hollerith(cardid[i] & 0x7F);
|
||||
putc(hol & 0xFF, fout);
|
||||
putc((hol >> 8) & 0xFF, fout);
|
||||
}
|
||||
|
||||
ndig = 0; // count trailing digits in the label
|
||||
for (i = 8; --i >= 0; ndig++)
|
||||
if (! isdigit(cardid[i]))
|
||||
break;
|
||||
|
||||
i++; // index of first digit in trailing sequence
|
||||
|
||||
if (ndig > 0) { // if any, increment them
|
||||
sprintf(fmt, "%%0%dd", ndig); // make, e.g. %03d
|
||||
sprintf(newdig, fmt, atoi(cardid+i)+1);
|
||||
newdig[ndig] = '\0'; // clip if necessary
|
||||
strcpy(cardid+i, newdig); // replace for next card's sequence number
|
||||
}
|
||||
}
|
||||
|
||||
outcols = 0;
|
||||
}
|
||||
|
||||
void show_data (unsigned short *buf)
|
||||
{
|
||||
int i, n, jrel, rflag, nout, ch, reloc;
|
||||
|
||||
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++];
|
||||
putchar('\n');
|
||||
printf(" ");
|
||||
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 loadcard (unsigned short *buf)
|
||||
{
|
||||
int addr, n, i;
|
||||
|
||||
addr = buf[0];
|
||||
n = buf[2] & 0x00FF;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (addr >= MAXADDR)
|
||||
bail("Program doesn't fit into 4K");
|
||||
mem[addr] = buf[9+i];
|
||||
|
||||
load_low = MIN(addr, load_low);
|
||||
load_high = MAX(addr, load_high);
|
||||
addr++;
|
||||
}
|
||||
}
|
||||
|
||||
void loaddata (char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
BOOL first = TRUE;
|
||||
unsigned short card[80], buf[54], cardtype;
|
||||
|
||||
if ((fp = fopen(fname, "rb")) == NULL) {
|
||||
perror(fname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
printf("\n%s:\n", fname);
|
||||
|
||||
while (fxread(card, sizeof(card[0]), 80, fp) > 0) {
|
||||
unpack(card, buf);
|
||||
verify_checksum(card);
|
||||
|
||||
cardtype = (buf[2] >> 8) & 0xFF;
|
||||
|
||||
if (cardtype == 1 && ! first) { // sector break
|
||||
if (verbose)
|
||||
printf("*SBRK\n");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
switch (cardtype) {
|
||||
case 0x01:
|
||||
if (verbose)
|
||||
printf("*ABS\n");
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
case 0x04:
|
||||
case 0x05:
|
||||
case 0x06:
|
||||
case 0x07:
|
||||
bail("Data must be in absolute format");
|
||||
break;
|
||||
|
||||
case 0x0F:
|
||||
pta = buf[3]; // save program transfer address
|
||||
if (verbose)
|
||||
printf("*END\n");
|
||||
break;
|
||||
|
||||
case 0x0A:
|
||||
if (verbose)
|
||||
show_data(buf);
|
||||
loadcard(buf);
|
||||
break;
|
||||
default:
|
||||
bail("Unexpected card type");
|
||||
}
|
||||
}
|
||||
first = FALSE;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void bail (char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void unpack (unsigned short *card, unsigned short *buf)
|
||||
{
|
||||
int i, j;
|
||||
unsigned short wd1, wd2, wd3, wd4;
|
||||
|
||||
for (i = j = 0; i < 54; i += 3, j += 4) {
|
||||
wd1 = card[j];
|
||||
wd2 = card[j+1];
|
||||
wd3 = card[j+2];
|
||||
wd4 = card[j+3];
|
||||
|
||||
buf[i ] = (wd1 & 0xFFF0) | ((wd2 >> 12) & 0x000F);
|
||||
buf[i+1] = ((wd2 << 4) & 0xFF00) | ((wd3 >> 8) & 0x00FF);
|
||||
buf[i+2] = ((wd3 << 8) & 0xF000) | ((wd4 >> 4) & 0x0FFF);
|
||||
}
|
||||
}
|
||||
|
||||
void verify_checksum (unsigned short *card)
|
||||
{
|
||||
// unsigned short sum;
|
||||
|
||||
if (card[1] == 0) // no checksum
|
||||
return;
|
||||
|
||||
// if (sum != card[1])
|
||||
// printf("Checksum %04x doesn't match card %04x\n", sum, card[1]);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int 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 ascii_to_hollerith (int ch)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(cardcode_029) / sizeof(CPCODE); i++)
|
||||
if (cardcode_029[i].ascii == ch)
|
||||
return cardcode_029[i].hollerith;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// corecard - routines to write IBM 1130 Card object format
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
unsigned short corecard[54]; // the 54 data words that can fit on a binary format card
|
||||
int corecard_n = 0; // number of object words stored in corecard (0-45)
|
||||
int corecard_seq = 1; // card output sequence number
|
||||
int corecard_org = 0; // origin of current card-full
|
||||
int corecard_maxaddr = 0;
|
||||
BOOL corecard_first = TRUE; // TRUE when we're to write the program type card
|
||||
|
||||
// corecard_init - prepare a new object data output card
|
||||
|
||||
void corecard_init (void)
|
||||
{
|
||||
memset(corecard, 0, sizeof(corecard)); // clear card data
|
||||
corecard_n = 0; // no data
|
||||
corecard[0] = corecard_org; // store load address
|
||||
corecard_maxaddr = MAX(corecard_maxaddr, corecard_org-1); // save highest address written-to (this may be a BSS)
|
||||
}
|
||||
|
||||
// binard_writecard - emit a card. sbrk_text = NULL for normal data cards, points to comment text for sbrk card
|
||||
|
||||
void corecard_writecard (char *sbrk_text)
|
||||
{
|
||||
unsigned short binout[80];
|
||||
int i, j;
|
||||
|
||||
for (i = j = 0; i < 54; i += 3, j += 4) {
|
||||
binout[j ] = ( corecard[i] & 0xFFF0);
|
||||
binout[j+1] = ((corecard[i] << 12) & 0xF000) | ((corecard[i+1] >> 4) & 0x0FF0);
|
||||
binout[j+2] = ((corecard[i+1] << 8) & 0xFF00) | ((corecard[i+2] >> 8) & 0x00F0);
|
||||
binout[j+3] = ((corecard[i+2] << 4) & 0xFFF0);
|
||||
}
|
||||
|
||||
for (i = 0; i < 72; i++) {
|
||||
putc(binout[i] & 0xFF, fout);
|
||||
putc((binout[i] >> 8) & 0xFF, fout);
|
||||
}
|
||||
|
||||
outcols = 72; // add the ident
|
||||
flushcard();
|
||||
}
|
||||
|
||||
// binard_writedata - emit an object data card
|
||||
|
||||
void corecard_writedata (void)
|
||||
{
|
||||
corecard[1] = 0; // checksum
|
||||
corecard[2] = 0x0000 | corecard_n; // data card type + word count
|
||||
corecard_writecard(FALSE); // emit the card
|
||||
}
|
||||
|
||||
// corecard_flush - flush any pending binary data
|
||||
|
||||
void corecard_flush (void)
|
||||
{
|
||||
if (corecard_n > 0)
|
||||
corecard_writedata();
|
||||
|
||||
corecard_init();
|
||||
}
|
||||
|
||||
// corecard_setorg - set the origin
|
||||
|
||||
void corecard_setorg (int neworg)
|
||||
{
|
||||
corecard_org = neworg; // set origin for next card
|
||||
corecard_flush(); // flush any current data & store origin
|
||||
}
|
||||
|
||||
// corecard_writew - write a word to the current output card.
|
||||
|
||||
void corecard_writew (int word, RELOC relative)
|
||||
{
|
||||
if (corecard_n >= 50) // flush full card buffer (must be even)
|
||||
corecard_flush();
|
||||
|
||||
corecard[3+corecard_n++] = word;
|
||||
corecard_org++;
|
||||
}
|
||||
|
||||
// corecard_endcard - write end of program card
|
||||
|
||||
void corecard_endcard (void)
|
||||
{
|
||||
corecard_flush();
|
||||
|
||||
corecard[0] = 0; // effective length: add 1 to max origin, then 1 more to round up
|
||||
corecard[1] = 0;
|
||||
corecard[2] = 0x8000; // they look for negative bit but all else must be zero
|
||||
corecard[52] = 0xabcd; // index register 3 value, this is for fun
|
||||
corecard[53] = pta; // hmmm
|
||||
|
||||
corecard_writecard(NULL);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* upcase - force a string to uppercase (ASCII)
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
char *upcase (char *str)
|
||||
{
|
||||
char *s;
|
||||
|
||||
for (s = str; *s; s++) {
|
||||
if (*s >= 'a' && *s <= 'z')
|
||||
*s -= 32;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
int strnicmp (char *a, char *b, int n)
|
||||
{
|
||||
int ca, cb;
|
||||
|
||||
for (;;) {
|
||||
if (--n < 0) // still equal after n characters? quit now
|
||||
return 0;
|
||||
|
||||
if ((ca = *a) == 0) // get character, stop on null terminator
|
||||
return *b ? -1 : 0;
|
||||
|
||||
if (ca >= 'a' && ca <= 'z') // fold lowercase to uppercase
|
||||
ca -= 32;
|
||||
|
||||
cb = *b;
|
||||
if (cb >= 'a' && cb <= 'z')
|
||||
cb -= 32;
|
||||
|
||||
if ((ca -= cb) != 0) // if different, return comparison
|
||||
return ca;
|
||||
|
||||
a++, b++;
|
||||
}
|
||||
}
|
||||
|
||||
int strcmpi (char *a, char *b)
|
||||
{
|
||||
int ca, cb;
|
||||
|
||||
for (;;) {
|
||||
if ((ca = *a) == 0) // get character, stop on null terminator
|
||||
return *b ? -1 : 0;
|
||||
|
||||
if (ca >= 'a' && ca <= 'z') // fold lowercase to uppercase
|
||||
ca -= 32;
|
||||
|
||||
cb = *b;
|
||||
if (cb >= 'a' && cb <= 'z')
|
||||
cb -= 32;
|
||||
|
||||
if ((ca -= cb) != 0) // if different, return comparison
|
||||
return ca;
|
||||
|
||||
a++, b++;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
175
Ibm1130/utils/mkboot.mak
Normal file
175
Ibm1130/utils/mkboot.mak
Normal file
@@ -0,0 +1,175 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "mkboot.mak" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/mkboot.exe $(OUTDIR)/mkboot.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"mkboot.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"mkboot.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/mkboot.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/mkboot.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console\
|
||||
/INCREMENTAL:no /PDB:$(OUTDIR)/"mkboot.pdb" /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"mkboot.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/mkboot.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/mkboot.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/mkboot.exe $(OUTDIR)/mkboot.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"mkboot.pch" /Fo$(INTDIR)/ /Fd$(OUTDIR)/"mkboot.pdb"\
|
||||
/c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"mkboot.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/mkboot.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/mkboot.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib /NOLOGO /SUBSYSTEM:console\
|
||||
/INCREMENTAL:yes /PDB:$(OUTDIR)/"mkboot.pdb" /DEBUG /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"mkboot.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/mkboot.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/mkboot.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\mkboot.c
|
||||
|
||||
$(INTDIR)/mkboot.obj : $(SOURCE) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util_io.c
|
||||
DEP_UTIL_=\
|
||||
.\util_io.h
|
||||
|
||||
$(INTDIR)/util_io.obj : $(SOURCE) $(DEP_UTIL_) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
243
Ibm1130/utils/viewdeck.c
Normal file
243
Ibm1130/utils/viewdeck.c
Normal file
@@ -0,0 +1,243 @@
|
||||
/* Simple program to display a binary card-image file in ASCII.
|
||||
* We assume the deck was written with one card per 16-bit word, left-justified,
|
||||
* and written in PC little-endian order
|
||||
*
|
||||
* (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
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "util_io.h"
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
typedef int BOOL;
|
||||
|
||||
int hollerith_to_ascii (unsigned short h);
|
||||
void bail (char *msg);
|
||||
void format_coldstart (unsigned short *buf);
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
FILE *fd;
|
||||
char *fname = NULL, line[82], *arg;
|
||||
BOOL coldstart = FALSE;
|
||||
unsigned short buf[80];
|
||||
int i, lastnb;
|
||||
static char usestr[] =
|
||||
"Usage: viewdeck [-c] deckfile\n"
|
||||
"\n"
|
||||
"-c: convert cold start card to 16-bit format as a C array initializer\n";
|
||||
|
||||
for (i = 1; i < argc; i++) { // process command line arguments
|
||||
arg = argv[i];
|
||||
|
||||
if (*arg == '-') {
|
||||
arg++;
|
||||
while (*arg) {
|
||||
switch (*arg++) {
|
||||
case 'c':
|
||||
coldstart = TRUE;
|
||||
break;
|
||||
default:
|
||||
bail(usestr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (fname == NULL) // first non-switch arg is file name
|
||||
fname = arg;
|
||||
else
|
||||
bail(usestr); // there can be only one name
|
||||
}
|
||||
|
||||
if (fname == NULL) // there must be a name
|
||||
bail(usestr);
|
||||
|
||||
if ((fd = fopen(fname, "rb")) == NULL) {
|
||||
perror(fname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (fxread(buf, sizeof(short), 80, fd) == 80) {
|
||||
if (coldstart) {
|
||||
format_coldstart(buf);
|
||||
break;
|
||||
}
|
||||
|
||||
lastnb = -1;
|
||||
for (i = 0; i < 80; i++) {
|
||||
line[i] = hollerith_to_ascii(buf[i]);
|
||||
if (line[i] > ' ')
|
||||
lastnb = i;
|
||||
}
|
||||
line[++lastnb] = '\n';
|
||||
line[++lastnb] = '\0';
|
||||
fputs(line, stdout);
|
||||
}
|
||||
|
||||
if (coldstart) {
|
||||
if (fxread(buf, sizeof(short), 1, fd) == 1)
|
||||
bail("Coldstart deck has more than one card");
|
||||
}
|
||||
|
||||
fclose(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void format_coldstart (unsigned short *buf)
|
||||
{
|
||||
int i, nout = 0;
|
||||
unsigned short word;
|
||||
|
||||
for (i = 0; i < 80; i++) {
|
||||
word = buf[i]; // expand 12-bit card data to 16-bit instruction
|
||||
word = (word & 0xF800) | ((word & 0x0400) ? 0x00C0 : 0x0000) | ((word & 0x03F0) >> 4);
|
||||
|
||||
if (nout >= 8) {
|
||||
fputs(",\n", stdout);
|
||||
nout = 0;
|
||||
}
|
||||
else if (i > 0)
|
||||
fputs(", ", stdout);
|
||||
|
||||
printf("0x%04x", word);
|
||||
nout++;
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
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, '\xA2', // cent, in MS-DOS encoding
|
||||
0x8420, '.',
|
||||
0x8220, '<', // ) in 026 Fortran
|
||||
0x8120, '(',
|
||||
0x80A0, '+',
|
||||
0x8060, '|',
|
||||
0x4820, '!',
|
||||
0x4420, '$',
|
||||
0x4220, '*',
|
||||
0x4120, ')',
|
||||
0x40A0, ';',
|
||||
0x4060, '\xAC', // not, in MS-DOS encoding
|
||||
0x2420, ',',
|
||||
0x2220, '%', // ( in 026 Fortran
|
||||
0x2120, '_',
|
||||
0x20A0, '>',
|
||||
0xB000, 'a',
|
||||
0xA800, 'b',
|
||||
0xA400, 'c',
|
||||
0xA200, 'd',
|
||||
0xA100, 'e',
|
||||
0xA080, 'f',
|
||||
0xA040, 'g',
|
||||
0xA020, 'h',
|
||||
0xA010, 'i',
|
||||
0xD000, 'j',
|
||||
0xC800, 'k',
|
||||
0xC400, 'l',
|
||||
0xC200, 'm',
|
||||
0xC100, 'n',
|
||||
0xC080, 'o',
|
||||
0xC040, 'p',
|
||||
0xC020, 'q',
|
||||
0xC010, 'r',
|
||||
0x6800, 's',
|
||||
0x6400, 't',
|
||||
0x6200, 'u',
|
||||
0x6100, 'v',
|
||||
0x6080, 'w',
|
||||
0x6040, 'x',
|
||||
0x6020, 'y',
|
||||
0x6010, 'z', // these odd punch codes are used by APL:
|
||||
0x1010, '\001', // no corresponding ASCII using ^A
|
||||
0x0810, '\002', // SYN using ^B
|
||||
0x0410, '\003', // no corresponding ASCII using ^C
|
||||
0x0210, '\004', // PUNCH ON using ^D
|
||||
0x0110, '\005', // READER STOP using ^E
|
||||
0x0090, '\006', // UPPER CASE using ^F
|
||||
0x0050, '\013', // EOT using ^K
|
||||
0x0030, '\016', // no corresponding ASCII using ^N
|
||||
0x1030, '\017', // no corresponding ASCII using ^O
|
||||
0x0830, '\020', // no corresponding ASCII using ^P
|
||||
};
|
||||
|
||||
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 '?';
|
||||
}
|
||||
|
||||
void bail (char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s\n", msg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
176
Ibm1130/utils/viewdeck.mak
Normal file
176
Ibm1130/utils/viewdeck.mak
Normal file
@@ -0,0 +1,176 @@
|
||||
# Microsoft Visual C++ Generated NMAKE File, Format Version 2.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Win32 Release" && "$(CFG)" != "Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "viewdeck.mak" CFG="Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "Win32 Debug"
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "WinRel"
|
||||
# PROP BASE Intermediate_Dir "WinRel"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "WinRel"
|
||||
# PROP Intermediate_Dir "WinRel"
|
||||
OUTDIR=.\WinRel
|
||||
INTDIR=.\WinRel
|
||||
|
||||
ALL : $(OUTDIR)/viewdeck.exe $(OUTDIR)/viewdeck.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /YX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"viewdeck.pch" /Fo$(INTDIR)/ /c
|
||||
CPP_OBJS=.\WinRel/
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"viewdeck.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/viewdeck.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/viewdeck.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib /NOLOGO /SUBSYSTEM:console /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:no\
|
||||
/PDB:$(OUTDIR)/"viewdeck.pdb" /MACHINE:I386 /OUT:$(OUTDIR)/"viewdeck.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/viewdeck.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/viewdeck.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "WinDebug"
|
||||
# PROP BASE Intermediate_Dir "WinDebug"
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "WinDebug"
|
||||
# PROP Intermediate_Dir "WinDebug"
|
||||
OUTDIR=.\WinDebug
|
||||
INTDIR=.\WinDebug
|
||||
|
||||
ALL : $(OUTDIR)/viewdeck.exe $(OUTDIR)/viewdeck.bsc
|
||||
|
||||
$(OUTDIR) :
|
||||
if not exist $(OUTDIR)/nul mkdir $(OUTDIR)
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
# ADD CPP /nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FR /c
|
||||
CPP_PROJ=/nologo /W3 /GX /Zi /YX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
|
||||
/FR$(INTDIR)/ /Fp$(OUTDIR)/"viewdeck.pch" /Fo$(INTDIR)/\
|
||||
/Fd$(OUTDIR)/"viewdeck.pdb" /c
|
||||
CPP_OBJS=.\WinDebug/
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o$(OUTDIR)/"viewdeck.bsc"
|
||||
BSC32_SBRS= \
|
||||
$(INTDIR)/viewdeck.sbr \
|
||||
$(INTDIR)/util_io.sbr
|
||||
|
||||
$(OUTDIR)/viewdeck.bsc : $(OUTDIR) $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib /NOLOGO /SUBSYSTEM:console /DEBUG /MACHINE:I386
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
|
||||
advapi32.lib /NOLOGO /SUBSYSTEM:console /INCREMENTAL:yes\
|
||||
/PDB:$(OUTDIR)/"viewdeck.pdb" /DEBUG /MACHINE:I386\
|
||||
/OUT:$(OUTDIR)/"viewdeck.exe"
|
||||
DEF_FILE=
|
||||
LINK32_OBJS= \
|
||||
$(INTDIR)/viewdeck.obj \
|
||||
$(INTDIR)/util_io.obj
|
||||
|
||||
$(OUTDIR)/viewdeck.exe : $(OUTDIR) $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Group "Source Files"
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\viewdeck.c
|
||||
|
||||
$(INTDIR)/viewdeck.obj : $(SOURCE) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util_io.c
|
||||
DEP_UTIL_=\
|
||||
.\util_io.h
|
||||
|
||||
$(INTDIR)/util_io.obj : $(SOURCE) $(DEP_UTIL_) $(INTDIR)
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Project
|
||||
################################################################################
|
||||
Reference in New Issue
Block a user