IBM1130: Convert Tabs to Spaces

This commit is contained in:
Mark Pizzolato 2017-05-03 15:11:22 -07:00
parent eea18400f3
commit 0c27d1f5a8
24 changed files with 12976 additions and 12976 deletions

View file

@ -11,33 +11,33 @@
/*
* 03 ctrl-C => Program stop (not handled here)
* 05 ctrl-E => Simulator stop (not handled here)
* 05 ctrl-E => Simulator stop (not handled here)
* 08 ctrl-H => Backspace
* 0D ctrl-M (Enter) => EOF
* 11 ctrl-Q => Interrupt request (not handled here)
* 12 ctrl-R => "cent" (R because that's where cent is on the 1130 keyboard)
* 12 ctrl-R => "cent" (R because that's where cent is on the 1130 keyboard)
* 15 ctrl-U => Erase Field
* 7E ~ => "not"
* FF Del => Backspace again
*/
static uint16 ascii_to_conin[] = /* ASCII to ((hollerith << 4) | special key flags) */
static uint16 ascii_to_conin[] = /* ASCII to ((hollerith << 4) | special key flags) */
{
/* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */
/* 00 */ 0, 0, 0, 0, 0, 0, 0, 0,0x0004, 0, 0, 0, 0,0x0008, 0, 0,
/* 10 */ 0, 0,0x8820, 0, 0,0x0002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 20 */ 0x0001,0x4820,0x0060,0x0420,0x4420,0x2220,0x8000,0x0120,0x8120,0x4120,0x4220,0x80a0,0x2420,0x4000,0x8420,0x3000,
/* 30 */ 0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0820,0x40a0,0x8220,0x00a0,0x20a0,0x2060,
/* 40 */ 0x0220,0x9000,0x8800,0x8400,0x8200,0x8100,0x8080,0x8040,0x8020,0x8010,0x5000,0x4800,0x4400,0x4200,0x4100,0x4080,
/* 50 */ 0x4040,0x4020,0x4010,0x2800,0x2400,0x2200,0x2100,0x2080,0x2040,0x2020,0x2010, 0, 0, 0, 0,0x2120,
/* 60 */ 0,0x9000,0x8800,0x8400,0x8200,0x8100,0x8080,0x8040,0x8020,0x8010,0x5000,0x4800,0x4400,0x4200,0x4100,0x4080,
/* 70 */ 0x4040,0x4020,0x4010,0x2800,0x2400,0x2200,0x2100,0x2080,0x2040,0x2020,0x2010, 0,0xB060, 0, 0,0x0004,
/* 80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* d0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* e0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* f0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0x0004,
/* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */
/* 00 */ 0, 0, 0, 0, 0, 0, 0, 0,0x0004, 0, 0, 0, 0,0x0008, 0, 0,
/* 10 */ 0, 0,0x8820, 0, 0,0x0002, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 20 */ 0x0001,0x4820,0x0060,0x0420,0x4420,0x2220,0x8000,0x0120,0x8120,0x4120,0x4220,0x80a0,0x2420,0x4000,0x8420,0x3000,
/* 30 */ 0x2000,0x1000,0x0800,0x0400,0x0200,0x0100,0x0080,0x0040,0x0020,0x0010,0x0820,0x40a0,0x8220,0x00a0,0x20a0,0x2060,
/* 40 */ 0x0220,0x9000,0x8800,0x8400,0x8200,0x8100,0x8080,0x8040,0x8020,0x8010,0x5000,0x4800,0x4400,0x4200,0x4100,0x4080,
/* 50 */ 0x4040,0x4020,0x4010,0x2800,0x2400,0x2200,0x2100,0x2080,0x2040,0x2020,0x2010, 0, 0, 0, 0,0x2120,
/* 60 */ 0,0x9000,0x8800,0x8400,0x8200,0x8100,0x8080,0x8040,0x8020,0x8010,0x5000,0x4800,0x4400,0x4200,0x4100,0x4080,
/* 70 */ 0x4040,0x4020,0x4010,0x2800,0x2400,0x2200,0x2100,0x2080,0x2040,0x2020,0x2010, 0,0xB060, 0, 0,0x0004,
/* 80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* a0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* b0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* c0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* d0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* e0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* f0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0x0004,
};

View file

@ -12,47 +12,47 @@
#define _0_ '\0'
#define CENT_ 0xA2 /* cent and not: standard DOS mapping */
#define NOT_ 0xAC
#define IGNR_ 0xFF
#define CRLF_ '\r'
#define CENT_ 0xA2 /* cent and not: standard DOS mapping */
#define NOT_ 0xAC
#define IGNR_ 0xFF
#define CRLF_ '\r'
#define COUT_IS_CTRL 0x01 /* conout characters with bit 1 set are controls: */
#define COUT_IS_CTRL 0x01 /* conout characters with bit 1 set are controls: */
#define COUT_CTRL_BLACK 0x04 /* none or one of these bits */
#define COUT_CTRL_RED 0x08
#define COUT_CTRL_BLACK 0x04 /* none or one of these bits */
#define COUT_CTRL_RED 0x08
#define COUT_CTRL_LINEFEED 0x02 /* plus none or one of these bits */
#define COUT_CTRL_BACKSPACE 0x10
#define COUT_CTRL_SPACE 0x20
#define COUT_CTRL_TAB 0x40
#define COUT_CTRL_RETURN 0x80
#define COUT_CTRL_LINEFEED 0x02 /* plus none or one of these bits */
#define COUT_CTRL_BACKSPACE 0x10
#define COUT_CTRL_SPACE 0x20
#define COUT_CTRL_TAB 0x40
#define COUT_CTRL_RETURN 0x80
#ifdef _MSC_VER
# pragma warning(disable:4245) /* enable int->char demotion warning caused by characters with high-bit set */
# pragma warning(disable:4245) /* enable int->char demotion warning caused by characters with high-bit set */
#endif
static unsigned char conout_to_ascii[] = /* console output code to ASCII */
static unsigned char conout_to_ascii[] = /* console output code to ASCII */
{
/* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */
/* 00 */ '.', IGNR_,CENT_, '\n', '@', IGNR_,'%', _0_, _0_, IGNR_,_0_, _0_, _0_, _0_, _0_, _0_,
/* 10 */ 'F', '\b', 'f', _0_, 'G', _0_, 'g', _0_, 'B', _0_, 'b', _0_, 'C', _0_, 'c', _0_,
/* 20 */ 'I', ' ', 'i', _0_, 'H', _0_, 'h', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 30 */ 'D', _0_, 'd', _0_, 'E', _0_, 'e', _0_, _0_, _0_, _0_, _0_, 'A', _0_, 'a', _0_,
/* 40 */ '$', '\t', '!', _0_, '&', _0_, '>', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 50 */ 'O', _0_, 'o', _0_, 'P', _0_, 'o', _0_, 'K', _0_, 'k', _0_, 'L', _0_, 'l', _0_,
/* 60 */ 'R', _0_, 'r', _0_, 'Q', _0_, 'q', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 70 */ 'M', _0_, 'm', _0_, 'N', _0_, 'n', _0_, _0_, _0_, _0_, _0_, 'J', _0_, 'j', _0_,
/* 80 */ ',', CRLF_, ':', _0_, '-', _0_, '?', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 90 */ 'W', _0_, 'w', _0_, 'X', _0_, 'x', _0_, 'S', _0_, 's', _0_, 'T', _0_, 't', _0_,
/* A0 */ 'Z', _0_, 'z', _0_, 'Y', _0_, 'y', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* B0 */ 'U', _0_, 'u', _0_, 'V', _0_, 'v', _0_, _0_, _0_, _0_, _0_, '/', _0_, '_', _0_,
/* C0 */ '#', _0_, '=', _0_, '0', _0_, '|', _0_, _0_, _0_, _0_, _0_, 'J', _0_, 'j', _0_,
/* D0 */ '6', _0_, ';', _0_, '7', _0_, '*', _0_, '2', _0_, '+', _0_, '3', _0_, '<', _0_,
/* E0 */ '9', _0_, '"', _0_, '8', _0_, '\'', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* F0 */ '4', _0_, NOT_, _0_, '5', _0_, ')', _0_, _0_, _0_, _0_, _0_, '1', _0_, '(', _0_,
/* 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F */
/* 00 */ '.', IGNR_,CENT_, '\n', '@', IGNR_,'%', _0_, _0_, IGNR_,_0_, _0_, _0_, _0_, _0_, _0_,
/* 10 */ 'F', '\b', 'f', _0_, 'G', _0_, 'g', _0_, 'B', _0_, 'b', _0_, 'C', _0_, 'c', _0_,
/* 20 */ 'I', ' ', 'i', _0_, 'H', _0_, 'h', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 30 */ 'D', _0_, 'd', _0_, 'E', _0_, 'e', _0_, _0_, _0_, _0_, _0_, 'A', _0_, 'a', _0_,
/* 40 */ '$', '\t', '!', _0_, '&', _0_, '>', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 50 */ 'O', _0_, 'o', _0_, 'P', _0_, 'o', _0_, 'K', _0_, 'k', _0_, 'L', _0_, 'l', _0_,
/* 60 */ 'R', _0_, 'r', _0_, 'Q', _0_, 'q', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 70 */ 'M', _0_, 'm', _0_, 'N', _0_, 'n', _0_, _0_, _0_, _0_, _0_, 'J', _0_, 'j', _0_,
/* 80 */ ',', CRLF_, ':', _0_, '-', _0_, '?', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* 90 */ 'W', _0_, 'w', _0_, 'X', _0_, 'x', _0_, 'S', _0_, 's', _0_, 'T', _0_, 't', _0_,
/* A0 */ 'Z', _0_, 'z', _0_, 'Y', _0_, 'y', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* B0 */ 'U', _0_, 'u', _0_, 'V', _0_, 'v', _0_, _0_, _0_, _0_, _0_, '/', _0_, '_', _0_,
/* C0 */ '#', _0_, '=', _0_, '0', _0_, '|', _0_, _0_, _0_, _0_, _0_, 'J', _0_, 'j', _0_,
/* D0 */ '6', _0_, ';', _0_, '7', _0_, '*', _0_, '2', _0_, '+', _0_, '3', _0_, '<', _0_,
/* E0 */ '9', _0_, '"', _0_, '8', _0_, '\'', _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_, _0_,
/* F0 */ '4', _0_, NOT_, _0_, '5', _0_, ')', _0_, _0_, _0_, _0_, _0_, '1', _0_, '(', _0_,
};
#ifdef _MSC_VER
# pragma warning(default:4245) /* enable int->char demotion warning */
# pragma warning(default:4245) /* enable int->char demotion warning */
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -12,15 +12,15 @@
/* ibm1130_defs.h: IBM-1130 simulator definitions
*/
#include "sim_defs.h" /* main SIMH defns (include path should include .., or make a copy) */
#include "sim_console.h" /* more SIMH defns (include path should include .., or make a copy) */
#include "sim_defs.h" /* main SIMH defns (include path should include .., or make a copy) */
#include "sim_console.h" /* more SIMH defns (include path should include .., or make a copy) */
#include <setjmp.h>
#include <assert.h>
#include <stdlib.h>
#if defined(VMS)
# include <unistd.h> /* to pick up 'unlink' */
# include <unistd.h> /* to pick up 'unlink' */
#endif
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
@ -31,65 +31,65 @@
int strcmpi (const char *a, const char *b);
#endif
/* #define GUI_SUPPORT uncomment to compile the GUI extensions. It's defined in the windows ibm1130.mak makefile */
/* #define GUI_SUPPORT uncomment to compile the GUI extensions. It's defined in the windows ibm1130.mak makefile */
/* ------------------------------------------------------------------------ */
/* Architectural constants */
#define MAXMEMSIZE (32768) /* 32Kwords */
#define INIMEMSIZE (16384) /* 16Kwords */
#define MEMSIZE (cpu_unit.capac)
#define MAXMEMSIZE (32768) /* 32Kwords */
#define INIMEMSIZE (16384) /* 16Kwords */
#define MEMSIZE (cpu_unit.capac)
#define ILL_ADR_FLAG 0x40000000 /* an impossible 1130 address */
#define ILL_ADR_FLAG 0x40000000 /* an impossible 1130 address */
/* ------------------------------------------------------------------------ */
/* Global state */
extern int cgi; /* TRUE if we are running as a CGI program */
extern int cgiwritable; /* TRUE if we can write the disk images back to the image file in CGI mode */
extern int cgi; /* TRUE if we are running as a CGI program */
extern int cgiwritable; /* TRUE if we can write the disk images back to the image file in CGI mode */
extern t_bool sim_gui;
extern uint16 M[]; /* core memory, up to 32Kwords (note: don't even think about trying 64K) */
extern uint16 ILSW[]; /* interrupt level status words */
extern int32 IAR; /* instruction address register */
extern int32 prev_IAR; /* instruction address register at start of current instruction */
extern int32 SAR, SBR; /* storage address/buffer registers */
extern int32 OP, TAG, CCC; /* instruction decoded pieces */
extern int32 CES; /* console entry switches */
extern int32 ACC, EXT; /* accumulator and extension */
extern int32 ARF; /* arithmetic factor register, a nonaddressable internal CPU register */
extern int32 RUNMODE; /* processor run/step mode */
extern int32 ipl; /* current interrupt level (-1 = not handling irq) */
extern int32 iplpending; /* interrupted IPL's */
extern int32 tbit; /* trace flag (causes level 5 IRQ after each instr) */
extern int32 V, C; /* condition codes */
extern int32 wait_state; /* wait state (waiting for an IRQ) */
extern int32 wait_lamp; /* alternate indicator to light the wait lamp on the GUI */
extern int32 int_req; /* sum of interrupt request levels active */
extern int32 int_lamps; /* accumulated version of int_req - gives lamp persistence */
extern int32 int_mask; /* current active interrupt mask (ipl sensitive) */
extern uint16 M[]; /* core memory, up to 32Kwords (note: don't even think about trying 64K) */
extern uint16 ILSW[]; /* interrupt level status words */
extern int32 IAR; /* instruction address register */
extern int32 prev_IAR; /* instruction address register at start of current instruction */
extern int32 SAR, SBR; /* storage address/buffer registers */
extern int32 OP, TAG, CCC; /* instruction decoded pieces */
extern int32 CES; /* console entry switches */
extern int32 ACC, EXT; /* accumulator and extension */
extern int32 ARF; /* arithmetic factor register, a nonaddressable internal CPU register */
extern int32 RUNMODE; /* processor run/step mode */
extern int32 ipl; /* current interrupt level (-1 = not handling irq) */
extern int32 iplpending; /* interrupted IPL's */
extern int32 tbit; /* trace flag (causes level 5 IRQ after each instr) */
extern int32 V, C; /* condition codes */
extern int32 wait_state; /* wait state (waiting for an IRQ) */
extern int32 wait_lamp; /* alternate indicator to light the wait lamp on the GUI */
extern int32 int_req; /* sum of interrupt request levels active */
extern int32 int_lamps; /* accumulated version of int_req - gives lamp persistence */
extern int32 int_mask; /* current active interrupt mask (ipl sensitive) */
extern int32 mem_mask;
extern int32 cpu_dsw; /* CPU device status word */
extern int32 con_dsw; /* has program stop and int run bits */
extern int32 cpu_dsw; /* CPU device status word */
extern int32 con_dsw; /* has program stop and int run bits */
extern t_bool running;
extern t_bool power;
extern t_bool cgi; /* TRUE if we are running as a CGI program */
extern t_bool cgiwritable; /* TRUE if we can write to the disk image file in CGI mode */
extern t_stat reason; /* CPU execution loop control */
extern t_bool cgi; /* TRUE if we are running as a CGI program */
extern t_bool cgiwritable; /* TRUE if we can write to the disk image file in CGI mode */
extern t_stat reason; /* CPU execution loop control */
#define WAIT_OP 1 /* wait state causes: wait instruction, invalid instruction*/
#define WAIT_OP 1 /* wait state causes: wait instruction, invalid instruction*/
#define WAIT_INVALID_OP 2
#define MODE_SS 3 /* RUNMODE values. SS and SMC are not implemented in this simulator */
#define MODE_SMC 2
#define MODE_INT_RUN 1
#define MODE_RUN 0
#define MODE_SI -1
#define MODE_DISP -2
#define MODE_LOAD -3
#define MODE_SS 3 /* RUNMODE values. SS and SMC are not implemented in this simulator */
#define MODE_SMC 2
#define MODE_INT_RUN 1
#define MODE_RUN 0
#define MODE_SI -1
#define MODE_DISP -2
#define MODE_LOAD -3
/* ------------------------------------------------------------------------ */
/* debugging */
/* debugging */
/* ------------------------------------------------------------------------ */
#define ENABLE_DEBUG_PRINT
@ -123,162 +123,162 @@ void WriteW (int32 a, int32 d);
/* ------------------------------------------------------------------------ */
/* Simulator stop codes */
#define STOP_WAIT 1 /* wait, no events */
#define STOP_INVALID_INSTR 2 /* bad instruction */
#define STOP_IBKPT 3 /* simulator breakpoint */
#define STOP_INCOMPLETE 4 /* simulator coding not complete here */
#define STOP_POWER_OFF 5 /* no power */
#define STOP_DECK_BREAK 6 /* !BREAK in deck file */
#define STOP_PHASE_BREAK 7 /* phase load break */
#define STOP_CRASH 8 /* program has crashed badly */
#define STOP_TIMED_OUT 9 /* simulation time limit exceeded */
#define STOP_IMMEDIATE 10 /* simulator stop key pressed (immediate stop) */
#define STOP_BREAK 11 /* simulator break key pressed */
#define STOP_STEP 12 /* step count expired */
#define STOP_OTHER 13 /* other reason, probably error returned by sim_process_event() */
#define STOP_PRINT_CHECK 14 /* stop due to printer check (used by CGI version) */
#define STOP_WAIT 1 /* wait, no events */
#define STOP_INVALID_INSTR 2 /* bad instruction */
#define STOP_IBKPT 3 /* simulator breakpoint */
#define STOP_INCOMPLETE 4 /* simulator coding not complete here */
#define STOP_POWER_OFF 5 /* no power */
#define STOP_DECK_BREAK 6 /* !BREAK in deck file */
#define STOP_PHASE_BREAK 7 /* phase load break */
#define STOP_CRASH 8 /* program has crashed badly */
#define STOP_TIMED_OUT 9 /* simulation time limit exceeded */
#define STOP_IMMEDIATE 10 /* simulator stop key pressed (immediate stop) */
#define STOP_BREAK 11 /* simulator break key pressed */
#define STOP_STEP 12 /* step count expired */
#define STOP_OTHER 13 /* other reason, probably error returned by sim_process_event() */
#define STOP_PRINT_CHECK 14 /* stop due to printer check (used by CGI version) */
#define IORETURN(f,v) ((f)? (v): SCPE_OK) /* cond error return */
#define IORETURN(f,v) ((f)? (v): SCPE_OK) /* cond error return */
#define INT_REQ_5 0x01 /* bits for interrupt levels (ipl, iplpending, int_req, int_mask) */
#define INT_REQ_4 0x02
#define INT_REQ_3 0x04
#define INT_REQ_2 0x08
#define INT_REQ_1 0x10
#define INT_REQ_0 0x20
#define INT_REQ_5 0x01 /* bits for interrupt levels (ipl, iplpending, int_req, int_mask) */
#define INT_REQ_4 0x02
#define INT_REQ_3 0x04
#define INT_REQ_2 0x08
#define INT_REQ_1 0x10
#define INT_REQ_0 0x20
#define XIO_UNUSED 0x00 /* XIO commands */
#define XIO_WRITE 0x01
#define XIO_READ 0x02
#define XIO_SENSE_IRQ 0x03
#define XIO_CONTROL 0x04
#define XIO_INITW 0x05
#define XIO_INITR 0x06
#define XIO_SENSE_DEV 0x07
#define XIO_UNUSED 0x00 /* XIO commands */
#define XIO_WRITE 0x01
#define XIO_READ 0x02
#define XIO_SENSE_IRQ 0x03
#define XIO_CONTROL 0x04
#define XIO_INITW 0x05
#define XIO_INITR 0x06
#define XIO_SENSE_DEV 0x07
#define XIO_FAILED 0x20 /* fake function to record error */
#define XIO_FAILED 0x20 /* fake function to record error */
/* ILSW bits - set by appropriate device whenever an interrupt is outstanding */
#define ILSW_0_1442_CARD 0x8000 /* ILSW 0 is not really defined on the 1130 */
#define ILSW_0_1442_CARD 0x8000 /* ILSW 0 is not really defined on the 1130 */
#define ILSW_1_1132_PRINTER 0x8000 /* had these backwards! */
#define ILSW_1_SCA 0x4000
#define ILSW_1_1132_PRINTER 0x8000 /* had these backwards! */
#define ILSW_1_SCA 0x4000
#define ILSW_2_1131_DISK 0x8000
#define ILSW_2_1131_DISK 0x8000
#define ILSW_2_2310_DRV_1 0x4000
#define ILSW_2_2310_DRV_2 0x2000
#define ILSW_2_2310_DRV_3 0x1000
#define ILSW_2_2310_DRV_4 0x0800 /* can have 2310 or 2311 */
#define ILSW_2_2310_DRV_1 0x4000
#define ILSW_2_2310_DRV_2 0x2000
#define ILSW_2_2310_DRV_3 0x1000
#define ILSW_2_2310_DRV_4 0x0800 /* can have 2310 or 2311 */
#define ILSW_2_2311_DRV_1_DISK_1 0x4000
#define ILSW_2_2311_DRV_1_DISK_2 0x2000
#define ILSW_2_2311_DRV_1_DISK_3 0x1000
#define ILSW_2_2311_DRV_1_DISK_4 0x0800
#define ILSW_2_2311_DRV_1_DISK_1 0x4000
#define ILSW_2_2311_DRV_1_DISK_2 0x2000
#define ILSW_2_2311_DRV_1_DISK_3 0x1000
#define ILSW_2_2311_DRV_1_DISK_4 0x0800
#define ILSW_2_2311_DRV_1_DISK_5 0x0400
#define ILSW_2_2311_DRV_2_DISK_1 0x0200
#define ILSW_2_2311_DRV_2_DISK_2 0x0100
#define ILSW_2_2311_DRV_2_DISK_3 0x0080
#define ILSW_2_2311_DRV_2_DISK_4 0x0040
#define ILSW_2_2311_DRV_2_DISK_5 0x0020
#define ILSW_2_2311_DRV_1_DISK_5 0x0400
#define ILSW_2_2311_DRV_2_DISK_1 0x0200
#define ILSW_2_2311_DRV_2_DISK_2 0x0100
#define ILSW_2_2311_DRV_2_DISK_3 0x0080
#define ILSW_2_2311_DRV_2_DISK_4 0x0040
#define ILSW_2_2311_DRV_2_DISK_5 0x0020
#define ILSW_2_SAC_BIT_11 0x0010
#define ILSW_2_SAC_BIT_12 0x0008
#define ILSW_2_SAC_BIT_13 0x0004
#define ILSW_2_SAC_BIT_14 0x0002
#define ILSW_2_SAC_BIT_15 0x0001
#define ILSW_2_SAC_BIT_11 0x0010
#define ILSW_2_SAC_BIT_12 0x0008
#define ILSW_2_SAC_BIT_13 0x0004
#define ILSW_2_SAC_BIT_14 0x0002
#define ILSW_2_SAC_BIT_15 0x0001
#define ILSW_3_1627_PLOTTER 0x8000
#define ILSW_3_SAC_BIT_01 0x4000
#define ILSW_3_SAC_BIT_02 0x2000
#define ILSW_3_SAC_BIT_03 0x1000
#define ILSW_3_2250_DISPLAY 0x0800
#define ILSW_3_SYSTEM7 0x0800
#define ILSW_3_SAC_BIT_05 0x0400
#define ILSW_3_SAC_BIT_06 0x0200
#define ILSW_3_SAC_BIT_07 0x0100
#define ILSW_3_SAC_BIT_08 0x0080
#define ILSW_3_SAC_BIT_09 0x0040
#define ILSW_3_SAC_BIT_10 0x0020
#define ILSW_3_SAC_BIT_11 0x0010
#define ILSW_3_SAC_BIT_12 0x0008
#define ILSW_3_SAC_BIT_13 0x0004
#define ILSW_3_SAC_BIT_14 0x0002
#define ILSW_3_SAC_BIT_15 0x0001
#define ILSW_3_1627_PLOTTER 0x8000
#define ILSW_3_SAC_BIT_01 0x4000
#define ILSW_3_SAC_BIT_02 0x2000
#define ILSW_3_SAC_BIT_03 0x1000
#define ILSW_3_2250_DISPLAY 0x0800
#define ILSW_3_SYSTEM7 0x0800
#define ILSW_3_SAC_BIT_05 0x0400
#define ILSW_3_SAC_BIT_06 0x0200
#define ILSW_3_SAC_BIT_07 0x0100
#define ILSW_3_SAC_BIT_08 0x0080
#define ILSW_3_SAC_BIT_09 0x0040
#define ILSW_3_SAC_BIT_10 0x0020
#define ILSW_3_SAC_BIT_11 0x0010
#define ILSW_3_SAC_BIT_12 0x0008
#define ILSW_3_SAC_BIT_13 0x0004
#define ILSW_3_SAC_BIT_14 0x0002
#define ILSW_3_SAC_BIT_15 0x0001
#define ILSW_4_1134_TAPE 0x8000
#define ILSW_4_1055_TAPE 0x8000
#define ILSW_4_CONSOLE 0x4000
#define ILSW_4_1442_CARD 0x2000
#define ILSW_4_2501_CARD 0x1000
#define ILSW_4_1403_PRINTER 0x0800
#define ILSW_4_1231_MARK 0x0400
#define ILSW_4_SAC_BIT_06 0x0200
#define ILSW_4_SAC_BIT_07 0x0100
#define ILSW_4_SAC_BIT_08 0x0080
#define ILSW_4_SAC_BIT_09 0x0040
#define ILSW_4_SAC_BIT_10 0x0020
#define ILSW_4_SAC_BIT_11 0x0010
#define ILSW_4_T2741_TERMINAL 0x0010 /* APL\1130 nonstandard serial interface uses this bit */
#define ILSW_4_SAC_BIT_12 0x0008
#define ILSW_4_SAC_BIT_13 0x0004
#define ILSW_4_SAC_BIT_14 0x0002
#define ILSW_4_SAC_BIT_15 0x0001
#define ILSW_4_1134_TAPE 0x8000
#define ILSW_4_1055_TAPE 0x8000
#define ILSW_4_CONSOLE 0x4000
#define ILSW_4_1442_CARD 0x2000
#define ILSW_4_2501_CARD 0x1000
#define ILSW_4_1403_PRINTER 0x0800
#define ILSW_4_1231_MARK 0x0400
#define ILSW_4_SAC_BIT_06 0x0200
#define ILSW_4_SAC_BIT_07 0x0100
#define ILSW_4_SAC_BIT_08 0x0080
#define ILSW_4_SAC_BIT_09 0x0040
#define ILSW_4_SAC_BIT_10 0x0020
#define ILSW_4_SAC_BIT_11 0x0010
#define ILSW_4_T2741_TERMINAL 0x0010 /* APL\1130 nonstandard serial interface uses this bit */
#define ILSW_4_SAC_BIT_12 0x0008
#define ILSW_4_SAC_BIT_13 0x0004
#define ILSW_4_SAC_BIT_14 0x0002
#define ILSW_4_SAC_BIT_15 0x0001
#define ILSW_5_INT_RUN_PROGRAM_STOP 0x8000 /* this replaces both ILSW_5_INT_RUN and ILSW_5_PROGRAM_STOP */
#define ILSW_5_SAC_BIT_01 0x4000
#define ILSW_5_SAC_BIT_02 0x2000
#define ILSW_5_SAC_BIT_03 0x1000
#define ILSW_5_SAC_BIT_04 0x0800
#define ILSW_5_SAC_BIT_05 0x0400
#define ILSW_5_SAC_BIT_06 0x0200
#define ILSW_5_SAC_BIT_07 0x0100
#define ILSW_5_SAC_BIT_08 0x0080
#define ILSW_5_SAC_BIT_09 0x0040
#define ILSW_5_SAC_BIT_10 0x0020
#define ILSW_5_SAC_BIT_11 0x0010
#define ILSW_5_SAC_BIT_12 0x0008
#define ILSW_5_SAC_BIT_13 0x0004
#define ILSW_5_SAC_BIT_14 0x0002
#define ILSW_5_SAC_BIT_15 0x0001
#define ILSW_5_INT_RUN_PROGRAM_STOP 0x8000 /* this replaces both ILSW_5_INT_RUN and ILSW_5_PROGRAM_STOP */
#define ILSW_5_SAC_BIT_01 0x4000
#define ILSW_5_SAC_BIT_02 0x2000
#define ILSW_5_SAC_BIT_03 0x1000
#define ILSW_5_SAC_BIT_04 0x0800
#define ILSW_5_SAC_BIT_05 0x0400
#define ILSW_5_SAC_BIT_06 0x0200
#define ILSW_5_SAC_BIT_07 0x0100
#define ILSW_5_SAC_BIT_08 0x0080
#define ILSW_5_SAC_BIT_09 0x0040
#define ILSW_5_SAC_BIT_10 0x0020
#define ILSW_5_SAC_BIT_11 0x0010
#define ILSW_5_SAC_BIT_12 0x0008
#define ILSW_5_SAC_BIT_13 0x0004
#define ILSW_5_SAC_BIT_14 0x0002
#define ILSW_5_SAC_BIT_15 0x0001
/* CPU DSW bits */
#define CPU_DSW_PROGRAM_STOP 0x8000
#define CPU_DSW_INT_RUN 0x4000
#define CPU_DSW_PROGRAM_STOP 0x8000
#define CPU_DSW_INT_RUN 0x4000
/* prototypes: xio handlers */
void xio_1131_console (int32 addr, int32 func, int32 modify); /* console keyboard and printer */
void xio_1442_card (int32 addr, int32 func, int32 modify); /* standard card reader/punch */
void xio_1134_papertape (int32 addr, int32 func, int32 modify); /* paper tape reader/punch */
void xio_disk (int32 addr, int32 func, int32 modify, int drv); /* internal CPU disk */
void xio_1627_plotter (int32 addr, int32 func, int32 modify); /* XY plotter */
void xio_1132_printer (int32 addr, int32 func, int32 modify); /* standard line printer */
void xio_1131_switches (int32 addr, int32 func, int32 modify); /* console buttons & switches */
void xio_1231_optical (int32 addr, int32 func, int32 modify); /* optical mark page reader */
void xio_2501_card (int32 addr, int32 func, int32 modify); /* alternate high-speed card reader */
void xio_sca (int32 addr, int32 func, int32 modify); /* synchronous communications adapter */
void xio_system7 (int32 addr, int32 func, int32 modify); /* system/7 interprocessor IO link */
void xio_1403_printer (int32 addr, int32 func, int32 modify); /* alternate high-speed printer */
void xio_2250_display (int32 addr, int32 func, int32 modify); /* vector display processor */
void xio_t2741_terminal (int32 addr, int32 func, int32 modify); /* IO selectric via nonstandard serial interface for APL */
void xio_error (const char *msg);
void xio_1131_console (int32 addr, int32 func, int32 modify); /* console keyboard and printer */
void xio_1442_card (int32 addr, int32 func, int32 modify); /* standard card reader/punch */
void xio_1134_papertape (int32 addr, int32 func, int32 modify); /* paper tape reader/punch */
void xio_disk (int32 addr, int32 func, int32 modify, int drv); /* internal CPU disk */
void xio_1627_plotter (int32 addr, int32 func, int32 modify); /* XY plotter */
void xio_1132_printer (int32 addr, int32 func, int32 modify); /* standard line printer */
void xio_1131_switches (int32 addr, int32 func, int32 modify); /* console buttons & switches */
void xio_1231_optical (int32 addr, int32 func, int32 modify); /* optical mark page reader */
void xio_2501_card (int32 addr, int32 func, int32 modify); /* alternate high-speed card reader */
void xio_sca (int32 addr, int32 func, int32 modify); /* synchronous communications adapter */
void xio_system7 (int32 addr, int32 func, int32 modify); /* system/7 interprocessor IO link */
void xio_1403_printer (int32 addr, int32 func, int32 modify); /* alternate high-speed printer */
void xio_2250_display (int32 addr, int32 func, int32 modify); /* vector display processor */
void xio_t2741_terminal (int32 addr, int32 func, int32 modify); /* IO selectric via nonstandard serial interface for APL */
void xio_error (const char *msg);
void bail (const char *msg);
t_stat load_cr_boot (int32 drv, int switches);
t_stat cr_boot (int32 unitno, DEVICE *dptr);
t_stat cr_rewind (void);
t_stat cr_detach (UNIT *uptr);
void calc_ints (void); /* recalculate interrupt bitmask */
void trace_io (const char *fmt, ...); /* debugging printout */
void trace_both (const char *fmt, ...); /* debugging printout */
void scp_panic (const char *msg); /* bail out of simulator */
void calc_ints (void); /* recalculate interrupt bitmask */
void trace_io (const char *fmt, ...); /* debugging printout */
void trace_both (const char *fmt, ...); /* debugging printout */
void scp_panic (const char *msg); /* bail out of simulator */
char *upcase(char *str);
void break_simulation (t_stat reason); /* let a device halt the simulation */
char hollerith_to_ascii (uint16 hol); /* for debugging use only */
void break_simulation (t_stat reason); /* let a device halt the simulation */
char hollerith_to_ascii (uint16 hol); /* for debugging use only */
t_bool gdu_active (void);
void remark_cmd (char *remark);
void stuff_cmd (char *cmd);
@ -291,9 +291,9 @@ CONST char * quotefix (CONST char *cptr, char * buf);
/* GUI interface routines */
t_bool keyboard_is_busy (void);
void forms_check (int set); /* device notification to console lamp display */
void forms_check (int set); /* device notification to console lamp display */
void print_check (int set);
void keyboard_selected (int select);
void keyboard_selected (int select);
void disk_ready (int ready);
void disk_unlocked (int unlocked);
void gui_run(int running);

File diff suppressed because it is too large Load diff

View file

@ -8,53 +8,53 @@
* into the appropriate column format. Three edit modes are recognized:
*
* Assembler mode:
* Input lines of the form
* Input lines of the form
*
* [label]<whitespace>[opcode]<tab>[tag][L]<tab>[argument]
* [label]<whitespace>[opcode]<tab>[tag][L]<tab>[argument]
*
* are rearranged so that the input fields are placed in the appropriate columns
* are rearranged so that the input fields are placed in the appropriate columns
*
* The label must start on the first character of the line. If there is no label,
* the first character(s) before the opcode must be whitespace. Following the opcode, there
* MUST be a tab character, followed by the format and tag. Following the format and tag
* may be exactly one whitespace character, and then starts the argument.
* The label must start on the first character of the line. If there is no label,
* the first character(s) before the opcode must be whitespace. Following the opcode, there
* MUST be a tab character, followed by the format and tag. Following the format and tag
* may be exactly one whitespace character, and then starts the argument.
*
* Input lines with * in column 1 and blank lines are turned into Assembler comments,
* with the * in the Opcode field.
* Input lines with * in column 1 and blank lines are turned into Assembler comments,
* with the * in the Opcode field.
*
* Assembler directive lines at the beginning of the deck must be preceded by
* ! to indicate that they are not comments. For example,
* Assembler directive lines at the beginning of the deck must be preceded by
* ! to indicate that they are not comments. For example,
*
* !*LIST
* * This is a comment
* !*LIST
* * This is a comment
*
* Fortran mode:
* Input lines of the form
* Input lines of the form
*
* [label]<tab>statement
* [label]<tab>statement
*
* or
* or
*
* [label]<tab>Xcontinuation
* [label]<tab>Xcontinuation
*
* where X is a non alphabetic contination character are rearranged in the
* appropriate manner:
* where X is a non alphabetic contination character are rearranged in the
* appropriate manner:
*
* 1 2
* 12345678901234567890...
* ------------------------
* label statement
* labelXcontinuation
* 1 2
* 12345678901234567890...
* ------------------------
* label statement
* labelXcontinuation
*
* However, you must take care that you don't end up with statement text after column 72.
* However, you must take care that you don't end up with statement text after column 72.
*
* Input lines with * or C in column 1 are left alone (comments and directives)
* Input lines with * or C in column 1 are left alone (comments and directives)
*
* (The ! escape is not used before Fortran directives as before Assembler directives)
* (The ! escape is not used before Fortran directives as before Assembler directives)
*
* Tab mode:
* Tabs are replaced with spaces. Tab settings are assumed to be eight characters wide,
* as is standard for vi, notepad, etc.
* Tabs are replaced with spaces. Tab settings are assumed to be eight characters wide,
* as is standard for vi, notepad, etc.
*********************************************************************************************/
#include <stdio.h>
@ -64,26 +64,26 @@
#include <string.h>
#include "ibm1130_fmt.h"
#define MAXLINE 81 /* maximum output line size */
#define WORKSZ 256 /* size for tab work area */
#define TAGOFFSET 12 /* offset for tag field */
#define FMTOFFSET 11 /* offset for format field */
#define MAXLINE 81 /* maximum output line size */
#define WORKSZ 256 /* size for tab work area */
#define TAGOFFSET 12 /* offset for tag field */
#define FMTOFFSET 11 /* offset for format field */
#define MIN(a,b) ((a < b) ? a : b)
#define AMSG " with Assembler Reformat"
#define FMSG " with FORTRAN Reformat"
#define WMSG " with tab replacement"
#define AFORMAT "%20.20s%-60.60s"," "
#define ACOMMENTFMT "%20.20s%-60.60s"," "
#define ABLANKLINE "%20.20s*"," "
#define FFORMAT "%-5.5s %-74.74s"
#define FCONTFMT "%-5.5s%-75.75s"
#define MIN(a,b) ((a < b) ? a : b)
#define AMSG " with Assembler Reformat"
#define FMSG " with FORTRAN Reformat"
#define WMSG " with tab replacement"
#define AFORMAT "%20.20s%-60.60s"," "
#define ACOMMENTFMT "%20.20s%-60.60s"," "
#define ABLANKLINE "%20.20s*"," "
#define FFORMAT "%-5.5s %-74.74s"
#define FCONTFMT "%-5.5s%-75.75s"
static char gszLabel[6]; /* work area for label */
static char gszArg[MAXLINE]; /* .. argument */
static char gszOutput[MAXLINE]; /* .. output */
static char gszLabel[6]; /* work area for label */
static char gszArg[MAXLINE]; /* .. argument */
static char gszOutput[MAXLINE]; /* .. output */
static short gaiAsmTabs[] = {7,12,15,20,25,30,35,40,45,52,0};/* tab stops for assembler */
static short gaiPlainTabs[42]; /* tab stops for plain tabs. Settings will be made later. Max # positions when tabs are every 2 positions */
static short gaiPlainTabs[42]; /* tab stops for plain tabs. Settings will be made later. Max # positions when tabs are every 2 positions */
static int giPlainTabWidth = 0;
/*
@ -94,135 +94,135 @@ static int giPlainTabWidth = 0;
* ExpandTabs: Expand tabs to spaces
*/
char* ExpandTabs(char* p_szInbuf, /* expand tabs .. input buffer */
char* p_szOutbuf, /* .. output buffer */
short* p_aiTabs) /* .. array of tab stops (1 based) -- 0 end of array */
char* ExpandTabs(char* p_szInbuf, /* expand tabs .. input buffer */
char* p_szOutbuf, /* .. output buffer */
short* p_aiTabs) /* .. array of tab stops (1 based) -- 0 end of array */
{
short iI, /* input position */
iO, /* output position */
iT; /* next tab stop */
char cX; /* character to test */
short iI, /* input position */
iO, /* output position */
iT; /* next tab stop */
char cX; /* character to test */
iI = 0; /* init input position */
iO = 0; /* init output position */
iT = 0; /* init tab stop */
while ((cX = *(p_szInbuf + iI)) != 0) /* while there are characters */
{
if (cX == '\t') /* q. tab character? */
{ /* a. yes .. */
while ((p_aiTabs[iT] <= iO + 1) /* search for next valid stop .. */
&& (p_aiTabs[iT] != 0)) /* .. or end of table */
iT++; /* .. go to next tab */
if (p_aiTabs[iT] != 0) /* q. end of tab array? */
{ /* a. no .. */
while (iO < (p_aiTabs[iT] - 1)) /* fill to tab with blanks */
*(p_szOutbuf + iO++) = ' '; /* .. put in a blank */
}
else /* Otherwise ... */
*(p_szOutbuf + iO++) = ' '; /* .. Translate to blank */
}
else /* Otherwise .. not tab */
*(p_szOutbuf + iO++) = cX; /* .. save the input char */
iI++; /* next input character */
}
*(p_szOutbuf + iO) = 0; /* end the string.. */
return p_szOutbuf; /* .. return output area addr */
iI = 0; /* init input position */
iO = 0; /* init output position */
iT = 0; /* init tab stop */
while ((cX = *(p_szInbuf + iI)) != 0) /* while there are characters */
{
if (cX == '\t') /* q. tab character? */
{ /* a. yes .. */
while ((p_aiTabs[iT] <= iO + 1) /* search for next valid stop .. */
&& (p_aiTabs[iT] != 0)) /* .. or end of table */
iT++; /* .. go to next tab */
if (p_aiTabs[iT] != 0) /* q. end of tab array? */
{ /* a. no .. */
while (iO < (p_aiTabs[iT] - 1)) /* fill to tab with blanks */
*(p_szOutbuf + iO++) = ' '; /* .. put in a blank */
}
else /* Otherwise ... */
*(p_szOutbuf + iO++) = ' '; /* .. Translate to blank */
}
else /* Otherwise .. not tab */
*(p_szOutbuf + iO++) = cX; /* .. save the input char */
iI++; /* next input character */
}
*(p_szOutbuf + iO) = 0; /* end the string.. */
return p_szOutbuf; /* .. return output area addr */
}
/*************************************************
* extract next token, modify pointer
*/
char* GetToken(char* p_szOut, /* output location */
int p_iLen, /* max output length */
char**p_pszToken) /* pointer to input token */
char* GetToken(char* p_szOut, /* output location */
int p_iLen, /* max output length */
char**p_pszToken) /* pointer to input token */
{
int iI; /* work integer */
char* pszX; /* work pointer */
int iI; /* work integer */
char* pszX; /* work pointer */
pszX = *p_pszToken; /* get pointer to token */
pszX = *p_pszToken; /* get pointer to token */
for (iI = 0; *(pszX + iI) && (!isspace(*(pszX + iI)));) /* while not whitespace & not end */
iI++; /* .. count token length */
for (iI = 0; *(pszX + iI) && (!isspace(*(pszX + iI)));) /* while not whitespace & not end */
iI++; /* .. count token length */
memset(p_szOut, 0, p_iLen); /* zero out output area */
memset(p_szOut, 0, p_iLen); /* zero out output area */
if (iI > 0) /* q. any chars? */
strncpy(p_szOut, *p_pszToken, MIN(iI, p_iLen-1)); /* a. yes.. copy max of p_iLen-1 */
if (iI > 0) /* q. any chars? */
strncpy(p_szOut, *p_pszToken, MIN(iI, p_iLen-1)); /* a. yes.. copy max of p_iLen-1 */
*p_pszToken += iI; /* point beyond token */
return p_szOut; /* .. return token pointer */
*p_pszToken += iI; /* point beyond token */
return p_szOut; /* .. return token pointer */
}
/*************************************************
* EditToAsm - convert tab-formatted text line to 1130 Assembler format
*/
const char *EditToAsm (char* p_pszEdit, int width) /* convert line to 1130 assembler */
const char *EditToAsm (char* p_pszEdit, int width) /* convert line to 1130 assembler */
{
char pszLine[MAXLINE]; /* source line */
char pszWork[WORKSZ]; /* work buffer */
char acTFWrk[2]; /* tag/format work area */
size_t iI; /* work integer */
char pszLine[MAXLINE]; /* source line */
char pszWork[WORKSZ]; /* work buffer */
char acTFWrk[2]; /* tag/format work area */
size_t iI; /* work integer */
if (p_pszEdit == NULL) /* q. null request? */
return AMSG; /* a. yes .. return display message */
if (p_pszEdit == NULL) /* q. null request? */
return AMSG; /* a. yes .. return display message */
if (*p_pszEdit == '!') /* leave lines starting with ! alone */
return EditToWhitespace(p_pszEdit+1, width);
if (*p_pszEdit == '!') /* leave lines starting with ! alone */
return EditToWhitespace(p_pszEdit+1, width);
if (*p_pszEdit == '*') /* q. comment line? */
{ /* a. yes.. */
strncpy(pszWork, EditToWhitespace(p_pszEdit, width), MAXLINE); /* .. convert any tabs */
sprintf(gszOutput, ACOMMENTFMT, pszWork); /* .. put the comment out there in the opcode column */
return gszOutput; /* .. and return it */
}
if (*p_pszEdit == '*') /* q. comment line? */
{ /* a. yes.. */
strncpy(pszWork, EditToWhitespace(p_pszEdit, width), MAXLINE); /* .. convert any tabs */
sprintf(gszOutput, ACOMMENTFMT, pszWork); /* .. put the comment out there in the opcode column */
return gszOutput; /* .. and return it */
}
strncpy(pszLine, p_pszEdit, MAXLINE-1); /* copy the line local */
ExpandTabs(pszLine, pszWork, gaiAsmTabs); /* expand the tabs */
strncpy(pszLine, pszWork, MAXLINE-1); /* copy the line back */
for (iI = strlen(pszLine); iI--;) /* trim trailing whitespace */
{
if (*(pszLine + iI) <= ' ') /* q. space or less? */
*(pszLine + iI) = 0; /* a. yes .. remove it */
else /* otherwise */
break; /* .. done. Leave loop. */
}
strncpy(pszLine, p_pszEdit, MAXLINE-1); /* copy the line local */
ExpandTabs(pszLine, pszWork, gaiAsmTabs); /* expand the tabs */
strncpy(pszLine, pszWork, MAXLINE-1); /* copy the line back */
for (iI = strlen(pszLine); iI--;) /* trim trailing whitespace */
{
if (*(pszLine + iI) <= ' ') /* q. space or less? */
*(pszLine + iI) = 0; /* a. yes .. remove it */
else /* otherwise */
break; /* .. done. Leave loop. */
}
if (strlen(pszLine) == 0) /* q. blank line? */
{ /* a. yes .. Assembler abhors these so */
sprintf(gszOutput, ABLANKLINE); /* format as comment statement */
return gszOutput; /* .. and return it */
}
if (strlen(pszLine) == 0) /* q. blank line? */
{ /* a. yes .. Assembler abhors these so */
sprintf(gszOutput, ABLANKLINE); /* format as comment statement */
return gszOutput; /* .. and return it */
}
/* TODO: Add code to process a strip switch
* comment?
*/
/* TODO: Add code to process a strip switch
* comment?
*/
if (strlen(pszLine) > (TAGOFFSET + 1)) /* q. line long enough? */
{ /* a. yes.. reorder tag/format */
memcpy(acTFWrk, pszLine + FMTOFFSET, 2); /* get tag/format */
memset((pszLine + FMTOFFSET), ' ', 2); /* .. blank 'em out */
for (iI = 0; iI < 2; iI ++)
if (isalpha(acTFWrk[iI])) /* q. alpha char? */
*(pszLine + FMTOFFSET) = acTFWrk[iI]; /* a. yes .. make it format */
else if (isdigit(acTFWrk[iI])) /* q. digit? */
*(pszLine + TAGOFFSET) = acTFWrk[iI]; /* a. yes .. make it the tag */
}
if (strlen(pszLine) > (TAGOFFSET + 1)) /* q. line long enough? */
{ /* a. yes.. reorder tag/format */
memcpy(acTFWrk, pszLine + FMTOFFSET, 2); /* get tag/format */
memset((pszLine + FMTOFFSET), ' ', 2); /* .. blank 'em out */
for (iI = 0; iI < 2; iI ++)
if (isalpha(acTFWrk[iI])) /* q. alpha char? */
*(pszLine + FMTOFFSET) = acTFWrk[iI]; /* a. yes .. make it format */
else if (isdigit(acTFWrk[iI])) /* q. digit? */
*(pszLine + TAGOFFSET) = acTFWrk[iI]; /* a. yes .. make it the tag */
}
sprintf(gszOutput, AFORMAT, pszLine); /* format the line */
return gszOutput; /* return formatted line */
sprintf(gszOutput, AFORMAT, pszLine); /* format the line */
return gszOutput; /* return formatted line */
}
/*************************************************
@ -230,99 +230,99 @@ size_t iI; /* work integer */
* (a la DEC Fortran)
*/
const char *EditToFortran(char* p_pszEdit, int width) /* convert line to 1130 assembler */
const char *EditToFortran(char* p_pszEdit, int width) /* convert line to 1130 assembler */
{
char pszLine[MAXLINE]; /* source line */
char* pszWork; /* work pointer */
size_t iI; /* work integer */
int bContinue; /* true if continue */
char pszLine[MAXLINE]; /* source line */
char* pszWork; /* work pointer */
size_t iI; /* work integer */
int bContinue; /* true if continue */
if (p_pszEdit == NULL) /* q. null request? */
return FMSG; /* a. yes .. return display message */
if (p_pszEdit == NULL) /* q. null request? */
return FMSG; /* a. yes .. return display message */
if (strchr(p_pszEdit, '\t') == NULL) /* q. no tab in the line? */
return p_pszEdit; /* a. nope, return line as is, assume it's formatted correctly */
if (strchr(p_pszEdit, '\t') == NULL) /* q. no tab in the line? */
return p_pszEdit; /* a. nope, return line as is, assume it's formatted correctly */
if (*p_pszEdit == 'C' || *p_pszEdit == '*' || *p_pszEdit == '\0') /* q. comment or directive or blank line? */
{ /* a. yes.. don't restructure */
return EditToWhitespace(p_pszEdit, width);
}
if (*p_pszEdit == 'C' || *p_pszEdit == '*' || *p_pszEdit == '\0') /* q. comment or directive or blank line? */
{ /* a. yes.. don't restructure */
return EditToWhitespace(p_pszEdit, width);
}
strncpy(pszLine, p_pszEdit, MAXLINE-1); /* copy the line local */
strncpy(pszLine, p_pszEdit, MAXLINE-1); /* copy the line local */
for (iI = strlen(pszLine); iI--;) /* trim trailing whitespace */
{
if (*(pszLine + iI) <= ' ') /* q. space or less? */
*(pszLine + iI) = 0; /* a. yes .. remove it */
else /* otherwise */
break; /* .. done. Leave loop. */
}
for (iI = strlen(pszLine); iI--;) /* trim trailing whitespace */
{
if (*(pszLine + iI) <= ' ') /* q. space or less? */
*(pszLine + iI) = 0; /* a. yes .. remove it */
else /* otherwise */
break; /* .. done. Leave loop. */
}
/*
* TODO: Add code to process a strip switch
* comment?
*/
/*
* TODO: Add code to process a strip switch
* comment?
*/
pszWork = (char*) pszLine; /* set pointer to line */
GetToken(gszLabel, 6, &pszWork); /* get the line, if any. */
pszWork = (char*) pszLine; /* set pointer to line */
GetToken(gszLabel, 6, &pszWork); /* get the line, if any. */
pszWork++; /* skip tab/whitespace */
pszWork++; /* skip tab/whitespace */
/* continuation... */
bContinue = ((isdigit(*pszWork) && (*pszWork != '0')) /* if first char non-zero digit */
|| (!isspace(*pszWork) && !isalpha(*pszWork))); /* .. or non-alpha non-blank */
memset(gszArg, 0, MAXLINE); /* .. and arguments */
/* continuation... */
bContinue = ((isdigit(*pszWork) && (*pszWork != '0')) /* if first char non-zero digit */
|| (!isspace(*pszWork) && !isalpha(*pszWork))); /* .. or non-alpha non-blank */
memset(gszArg, 0, MAXLINE); /* .. and arguments */
strncpy(gszArg, pszWork, 75); /* copy rest to argument */
strncpy(gszArg, pszWork, 75); /* copy rest to argument */
sprintf(gszOutput, (bContinue) ? FCONTFMT : FFORMAT, /* format the line */
gszLabel, /* .. statement # */
gszArg); /* .. code */
return gszOutput; /* return formatted line */
sprintf(gszOutput, (bContinue) ? FCONTFMT : FFORMAT, /* format the line */
gszLabel, /* .. statement # */
gszArg); /* .. code */
return gszOutput; /* return formatted line */
}
/*************************************************
* EditToWhitespace - expand tabs at n space intervals.
*/
const char* EditToWhitespace(char *p_pszEdit, int width)
const char* EditToWhitespace(char *p_pszEdit, int width)
{
int iI; /* work integer */
int iI; /* work integer */
int iPos; /* work integer for settings tab stops */
char pszLine[MAXLINE]; /* source line */
char pszWork[WORKSZ]; /* work buffer */
char pszLine[MAXLINE]; /* source line */
char pszWork[WORKSZ]; /* work buffer */
if (p_pszEdit == NULL) /* q. null request? */
return WMSG; /* a. yes .. return display message */
if (p_pszEdit == NULL) /* q. null request? */
return WMSG; /* a. yes .. return display message */
strncpy(pszLine, p_pszEdit, MAXLINE-1); /* copy the line local */
strncpy(pszLine, p_pszEdit, MAXLINE-1); /* copy the line local */
if (width == 0) width = 8; /* default */
if (width == 0) width = 8; /* default */
if ((width != giPlainTabWidth) && (width > 1) && (width < 30)) {
giPlainTabWidth = width; /* if width is different, and valid, rebuild tabstop array */
iI = 0; /* output index */
iPos = width + 1; /* first tab position */
while (iPos < 80) { /* fill array up to but not including position 80 */
gaiPlainTabs[iI++] = iPos;
iPos += width;
}
gaiPlainTabs[iI] = 0; /* mark end of array */
}
ExpandTabs(pszLine, pszWork, gaiPlainTabs); /* expand the tabs */
strncpy(gszOutput, pszWork, MAXLINE-1); /* copy the line back */
for (iI = strlen(gszOutput); iI--;) /* look at each character */
{
if (*(gszOutput + iI) <= ' ') /* q. space or less? */
*(gszOutput + iI) = 0; /* a. yes .. remove it */
else /* otherwise */
break; /* .. done. Leave loop. */
}
if ((width != giPlainTabWidth) && (width > 1) && (width < 30)) {
giPlainTabWidth = width; /* if width is different, and valid, rebuild tabstop array */
iI = 0; /* output index */
iPos = width + 1; /* first tab position */
while (iPos < 80) { /* fill array up to but not including position 80 */
gaiPlainTabs[iI++] = iPos;
iPos += width;
}
gaiPlainTabs[iI] = 0; /* mark end of array */
}
ExpandTabs(pszLine, pszWork, gaiPlainTabs); /* expand the tabs */
strncpy(gszOutput, pszWork, MAXLINE-1); /* copy the line back */
for (iI = strlen(gszOutput); iI--;) /* look at each character */
{
if (*(gszOutput + iI) <= ' ') /* q. space or less? */
*(gszOutput + iI) = 0; /* a. yes .. remove it */
else /* otherwise */
break; /* .. done. Leave loop. */
}
return gszOutput; /* ... return buffer */
return gszOutput; /* ... return buffer */
}

View file

@ -12,6 +12,6 @@
/* ibm1130_asm.h: definition of routines in ibm1130_asm.c
*/
const char* EditToAsm(char* str, int width); /* convert edit format to 1130 assembler format */
const char* EditToFortran(char* str, int width); /* convert edit format to Fortran format */
const char* EditToWhitespace(char* str, int width); /* clean white space, tabstops every 8 positions */
const char* EditToAsm(char* str, int width); /* convert edit format to 1130 assembler format */
const char* EditToFortran(char* str, int width); /* convert edit format to Fortran format */
const char* EditToWhitespace(char* str, int width); /* clean white space, tabstops every 8 positions */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -10,115 +10,115 @@
*/
struct tag_codewheel {
unsigned char ascii;
unsigned char ebcdic;
unsigned char ascii;
unsigned char ebcdic;
};
static struct tag_codewheel codewheel1132[] =
{ /* characters and EBCDIC codes in printwheel order */
{'A', 0xC1},
{'B', 0xC2},
{'C', 0xC3},
{'D', 0xC4},
{'F', 0xC6},
{'H', 0xC8},
{'I', 0xC9},
{'S', 0xE2},
{'T', 0xE3},
{'U', 0xE4},
{'V', 0xE5},
{'1', 0xF1},
{'2', 0xF2},
{'3', 0xF3},
{'4', 0xF4},
{'5', 0xF5},
{'6', 0xF6},
{'7', 0xF7},
{'8', 0xF8},
{'9', 0xF9},
{'0', 0xF0},
{'=', 0x7E},
{'$', 0x5B},
{'.', 0x4B},
{'\'', 0x7D},
{',', 0x6B},
{')', 0x5D},
{'-', 0x60},
{'(', 0x4D},
{'+', 0x4E},
{'/', 0x61},
{'*', 0x5C},
{'&', 0x50},
{'J', 0xD1},
{'K', 0xD2},
{'L', 0xD3},
{'M', 0xD4},
{'N', 0xD5},
{'O', 0xD6},
{'P', 0xD7},
{'Q', 0xD8},
{'R', 0xD9},
{'E', 0xC5},
{'G', 0xC7},
{'W', 0xE6},
{'X', 0xE7},
{'Y', 0xE8},
{'Z', 0xE9},
{ /* characters and EBCDIC codes in printwheel order */
{'A', 0xC1},
{'B', 0xC2},
{'C', 0xC3},
{'D', 0xC4},
{'F', 0xC6},
{'H', 0xC8},
{'I', 0xC9},
{'S', 0xE2},
{'T', 0xE3},
{'U', 0xE4},
{'V', 0xE5},
{'1', 0xF1},
{'2', 0xF2},
{'3', 0xF3},
{'4', 0xF4},
{'5', 0xF5},
{'6', 0xF6},
{'7', 0xF7},
{'8', 0xF8},
{'9', 0xF9},
{'0', 0xF0},
{'=', 0x7E},
{'$', 0x5B},
{'.', 0x4B},
{'\'', 0x7D},
{',', 0x6B},
{')', 0x5D},
{'-', 0x60},
{'(', 0x4D},
{'+', 0x4E},
{'/', 0x61},
{'*', 0x5C},
{'&', 0x50},
{'J', 0xD1},
{'K', 0xD2},
{'L', 0xD3},
{'M', 0xD4},
{'N', 0xD5},
{'O', 0xD6},
{'P', 0xD7},
{'Q', 0xD8},
{'R', 0xD9},
{'E', 0xC5},
{'G', 0xC7},
{'W', 0xE6},
{'X', 0xE7},
{'Y', 0xE8},
{'Z', 0xE9},
};
#define WHEELCHARS_1132 (sizeof(codewheel1132)/sizeof(codewheel1132[0]))
static struct tag_codewheel codewheel1403[] =
{
{'A', 0x64},
{'B', 0x25},
{'C', 0x26},
{'D', 0x67},
{'E', 0x68},
{'F', 0x29},
{'G', 0x2A},
{'H', 0x6B},
{'I', 0x2C},
{'J', 0x58},
{'K', 0x19},
{'L', 0x1A},
{'M', 0x5B},
{'N', 0x1C},
{'O', 0x5D},
{'P', 0x5E},
{'Q', 0x1F},
{'R', 0x20},
{'S', 0x0D},
{'T', 0x0E},
{'U', 0x4F},
{'V', 0x10},
{'W', 0x51},
{'X', 0x52},
{'Y', 0x13},
{'Z', 0x54},
{'0', 0x49},
{'1', 0x40},
{'2', 0x01},
{'3', 0x02},
{'4', 0x43},
{'5', 0x04},
{'6', 0x45},
{'7', 0x46},
{'8', 0x07},
{'9', 0x08},
{' ', 0x7F},
{'.', 0x6E},
{'(', 0x57},
{'+', 0x6D},
{'&', 0x15},
{'$', 0x62},
{'*', 0x23},
{')', 0x2F},
{'-', 0x61},
{'/', 0x4C},
{',', 0x16},
{'\'', 0x0B},
{'=', 0x4A},
{'A', 0x64},
{'B', 0x25},
{'C', 0x26},
{'D', 0x67},
{'E', 0x68},
{'F', 0x29},
{'G', 0x2A},
{'H', 0x6B},
{'I', 0x2C},
{'J', 0x58},
{'K', 0x19},
{'L', 0x1A},
{'M', 0x5B},
{'N', 0x1C},
{'O', 0x5D},
{'P', 0x5E},
{'Q', 0x1F},
{'R', 0x20},
{'S', 0x0D},
{'T', 0x0E},
{'U', 0x4F},
{'V', 0x10},
{'W', 0x51},
{'X', 0x52},
{'Y', 0x13},
{'Z', 0x54},
{'0', 0x49},
{'1', 0x40},
{'2', 0x01},
{'3', 0x02},
{'4', 0x43},
{'5', 0x04},
{'6', 0x45},
{'7', 0x46},
{'8', 0x07},
{'9', 0x08},
{' ', 0x7F},
{'.', 0x6E},
{'(', 0x57},
{'+', 0x6D},
{'&', 0x15},
{'$', 0x62},
{'*', 0x23},
{')', 0x2F},
{'-', 0x61},
{'/', 0x4C},
{',', 0x16},
{'\'', 0x0B},
{'=', 0x4A},
};
#define WHEELCHARS_1403 (sizeof(codewheel1403)/sizeof(codewheel1403[0]))

View file

@ -20,16 +20,16 @@
#include "ibm1130_defs.h"
/***************************************************************************************
* 1134 Paper Tape Reader device PTR
* 1055 Paper Tape Punch device PTP (shares DSW with PTR)
* 1134 Paper Tape Reader device PTR
* 1055 Paper Tape Punch device PTP (shares DSW with PTR)
***************************************************************************************/
#define PTR1134_DSW_READER_RESPONSE 0x4000
#define PTR1134_DSW_PUNCH_RESPONSE 0x1000
#define PTR1134_DSW_READER_BUSY 0x0800
#define PTR1134_DSW_READER_NOT_READY 0x0400
#define PTR1134_DSW_PUNCH_BUSY 0x0200
#define PTR1134_DSW_PUNCH_NOT_READY 0x0100
#define PTR1134_DSW_READER_RESPONSE 0x4000
#define PTR1134_DSW_PUNCH_RESPONSE 0x1000
#define PTR1134_DSW_READER_BUSY 0x0800
#define PTR1134_DSW_READER_NOT_READY 0x0400
#define PTR1134_DSW_PUNCH_BUSY 0x0200
#define PTR1134_DSW_PUNCH_NOT_READY 0x0100
#define IS_ONLINE(u) (((u)->flags & (UNIT_ATT|UNIT_DIS)) == UNIT_ATT)
@ -37,273 +37,273 @@ static t_stat ptr_svc (UNIT *uptr);
static t_stat ptr_reset (DEVICE *dptr);
static t_stat ptr_attach (UNIT *uptr, CONST char *cptr);
static t_stat ptr_detach (UNIT *uptr);
static t_stat ptr_boot (int32 unitno, DEVICE *dptr);
static t_stat ptr_boot (int32 unitno, DEVICE *dptr);
static t_stat ptp_svc (UNIT *uptr);
static t_stat ptp_reset (DEVICE *dptr);
static t_stat ptp_attach (UNIT *uptr, CONST char *cptr);
static t_stat ptp_detach (UNIT *uptr);
static int16 ptr_dsw = 0; /* device status word */
static int32 ptr_wait = 1000; /* character read wait */
static uint8 ptr_char = 0; /* last character read */
static int32 ptp_wait = 1000; /* character punch wait */
static int16 ptr_dsw = 0; /* device status word */
static int32 ptr_wait = 1000; /* character read wait */
static uint8 ptr_char = 0; /* last character read */
static int32 ptp_wait = 1000; /* character punch wait */
UNIT ptr_unit[1] = {
{ UDATA (&ptr_svc, UNIT_ATTABLE, 0) },
{ UDATA (&ptr_svc, UNIT_ATTABLE, 0) },
};
REG ptr_reg[] = {
{ HRDATA (DSW, ptr_dsw, 16) }, /* device status word */
{ DRDATA (WTIME, ptr_wait, 24), PV_LEFT }, /* character read wait */
{ DRDATA (LASTCHAR, ptr_char, 8), PV_LEFT }, /* last character read */
{ NULL } };
{ HRDATA (DSW, ptr_dsw, 16) }, /* device status word */
{ DRDATA (WTIME, ptr_wait, 24), PV_LEFT }, /* character read wait */
{ DRDATA (LASTCHAR, ptr_char, 8), PV_LEFT }, /* last character read */
{ NULL } };
DEVICE ptr_dev = {
"PTR", ptr_unit, ptr_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, ptr_reset,
ptr_boot, ptr_attach, ptr_detach};
"PTR", ptr_unit, ptr_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, ptr_reset,
ptr_boot, ptr_attach, ptr_detach};
UNIT ptp_unit[1] = {
{ UDATA (&ptp_svc, UNIT_ATTABLE, 0) },
{ UDATA (&ptp_svc, UNIT_ATTABLE, 0) },
};
REG ptp_reg[] = {
{ HRDATA (DSW, ptr_dsw, 16) }, /* device status word (this is the same as the reader's!) */
{ DRDATA (WTIME, ptp_wait, 24), PV_LEFT }, /* character punch wait */
{ NULL } };
{ HRDATA (DSW, ptr_dsw, 16) }, /* device status word (this is the same as the reader's!) */
{ DRDATA (WTIME, ptp_wait, 24), PV_LEFT }, /* character punch wait */
{ NULL } };
DEVICE ptp_dev = {
"PTP", ptp_unit, ptp_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, ptp_reset,
NULL, ptp_attach, ptp_detach};
"PTP", ptp_unit, ptp_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, ptp_reset,
NULL, ptp_attach, ptp_detach};
/* xio_1134_papertape - XIO command interpreter for the 1134 paper tape reader and 1055 paper tape punch */
void xio_1134_papertape (int32 iocc_addr, int32 iocc_func, int32 iocc_mod)
{
char msg[80];
char msg[80];
switch (iocc_func) {
case XIO_READ: /* read: return last character read */
M[iocc_addr & mem_mask] = (uint16) (ptr_char << 8);
break;
switch (iocc_func) {
case XIO_READ: /* read: return last character read */
M[iocc_addr & mem_mask] = (uint16) (ptr_char << 8);
break;
case XIO_WRITE: /* write: initiate punch operation */
if ((ptr_dsw & PTR1134_DSW_PUNCH_NOT_READY) == 0 && IS_ONLINE(ptp_unit)) {
putc((M[iocc_addr & mem_mask] >> 8) & 0xFF, ptp_unit->fileref);
ptp_unit->pos++;
}
sim_activate(ptp_unit, ptp_wait); /* schedule interrupt */
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY | PTR1134_DSW_PUNCH_BUSY);
break;
case XIO_WRITE: /* write: initiate punch operation */
if ((ptr_dsw & PTR1134_DSW_PUNCH_NOT_READY) == 0 && IS_ONLINE(ptp_unit)) {
putc((M[iocc_addr & mem_mask] >> 8) & 0xFF, ptp_unit->fileref);
ptp_unit->pos++;
}
sim_activate(ptp_unit, ptp_wait); /* schedule interrupt */
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY | PTR1134_DSW_PUNCH_BUSY);
break;
case XIO_SENSE_DEV: /* sense device status */
ACC = ptr_dsw;
if (iocc_mod & 0x01) { /* reset interrupts */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_RESPONSE | PTR1134_DSW_PUNCH_RESPONSE);
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
}
break;
case XIO_SENSE_DEV: /* sense device status */
ACC = ptr_dsw;
if (iocc_mod & 0x01) { /* reset interrupts */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_RESPONSE | PTR1134_DSW_PUNCH_RESPONSE);
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
}
break;
case XIO_CONTROL: /* control: initiate character read */
sim_activate(ptr_unit, ptr_wait); /* schedule interrupt */
SETBIT(ptr_dsw, PTR1134_DSW_READER_BUSY | PTR1134_DSW_READER_NOT_READY);
break;
case XIO_CONTROL: /* control: initiate character read */
sim_activate(ptr_unit, ptr_wait); /* schedule interrupt */
SETBIT(ptr_dsw, PTR1134_DSW_READER_BUSY | PTR1134_DSW_READER_NOT_READY);
break;
default:
sprintf(msg, "Invalid 1134 reader/1055 punch XIO function %x", iocc_func);
xio_error(msg);
}
default:
sprintf(msg, "Invalid 1134 reader/1055 punch XIO function %x", iocc_func);
xio_error(msg);
}
}
/* ptr_svc - emulated timeout - 1134 read operation complete */
static t_stat ptr_svc (UNIT *uptr)
{
CLRBIT(ptr_dsw, PTR1134_DSW_READER_BUSY); /* clear reader busy flag */
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* assume at end of file */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_BUSY); /* clear reader busy flag */
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* assume at end of file */
if (IS_ONLINE(uptr)) { /* fetch character from file */
ptr_char = getc(uptr->fileref);
uptr->pos++;
if (IS_ONLINE(uptr)) { /* fetch character from file */
ptr_char = getc(uptr->fileref);
uptr->pos++;
if (! feof(uptr->fileref)) /* there's more left */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
}
if (! feof(uptr->fileref)) /* there's more left */
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
}
SETBIT(ptr_dsw, PTR1134_DSW_READER_RESPONSE); /* indicate read complete */
SETBIT(ptr_dsw, PTR1134_DSW_READER_RESPONSE); /* indicate read complete */
SETBIT(ILSW[4], ILSW_4_1134_TAPE); /* initiate interrupt */
calc_ints();
SETBIT(ILSW[4], ILSW_4_1134_TAPE); /* initiate interrupt */
calc_ints();
return SCPE_OK;
return SCPE_OK;
}
/* ptp_svc - emulated timeout -- 1055 punch operation complete */
static t_stat ptp_svc (UNIT *uptr)
{
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_BUSY); /* clear punch busy flag */
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_BUSY); /* clear punch busy flag */
if (IS_ONLINE(uptr)) /* update punch ready status */
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
else
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_RESPONSE); /* indicate punch complete */
if (IS_ONLINE(uptr)) /* update punch ready status */
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
else
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_RESPONSE); /* indicate punch complete */
SETBIT(ILSW[4], ILSW_4_1134_TAPE); /* initiate interrupt */
calc_ints();
SETBIT(ILSW[4], ILSW_4_1134_TAPE); /* initiate interrupt */
calc_ints();
return SCPE_OK;
return SCPE_OK;
}
/* ptr_reset - reset emulated paper tape reader */
static t_stat ptr_reset (DEVICE *dptr)
{
sim_cancel(ptr_unit);
sim_cancel(ptr_unit);
CLRBIT(ptr_dsw, PTR1134_DSW_READER_BUSY | PTR1134_DSW_READER_RESPONSE);
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
CLRBIT(ptr_dsw, PTR1134_DSW_READER_BUSY | PTR1134_DSW_READER_RESPONSE);
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
if (IS_ONLINE(ptr_unit) && ! feof(ptr_unit->fileref))
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
if (IS_ONLINE(ptr_unit) && ! feof(ptr_unit->fileref))
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
if ((ptr_dsw & PTR1134_DSW_PUNCH_RESPONSE) == 0) { /* punch isn't interrupting either */
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
calc_ints();
}
if ((ptr_dsw & PTR1134_DSW_PUNCH_RESPONSE) == 0) { /* punch isn't interrupting either */
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
calc_ints();
}
return SCPE_OK;
return SCPE_OK;
}
/* ptp_reset - reset emulated paper tape punch */
static t_stat ptp_reset (DEVICE *dptr)
{
sim_cancel(ptp_unit);
sim_cancel(ptp_unit);
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_BUSY | PTR1134_DSW_PUNCH_RESPONSE);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_BUSY | PTR1134_DSW_PUNCH_RESPONSE);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
if (IS_ONLINE(ptp_unit))
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
if (IS_ONLINE(ptp_unit))
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
if ((ptr_dsw & PTR1134_DSW_READER_RESPONSE) == 0) { /* reader isn't interrupting either */
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
calc_ints();
}
if ((ptr_dsw & PTR1134_DSW_READER_RESPONSE) == 0) { /* reader isn't interrupting either */
CLRBIT(ILSW[4], ILSW_4_1134_TAPE);
calc_ints();
}
return SCPE_OK;
return SCPE_OK;
}
/* ptr_attach - attach file to simulated paper tape reader */
static t_stat ptr_attach (UNIT *uptr, CONST char *cptr)
{
t_stat rval;
t_stat rval;
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* assume failure */
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* assume failure */
if ((rval = attach_unit(uptr, cptr)) != SCPE_OK) /* use standard attach */
return rval;
if ((rval = attach_unit(uptr, cptr)) != SCPE_OK) /* use standard attach */
return rval;
if ((ptr_dsw & PTR1134_DSW_READER_BUSY) == 0 && ! feof(uptr->fileref))
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* we're in business */
if ((ptr_dsw & PTR1134_DSW_READER_BUSY) == 0 && ! feof(uptr->fileref))
CLRBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY); /* we're in business */
return SCPE_OK;
return SCPE_OK;
}
/* ptr_attach - detach file from simulated paper tape reader */
static t_stat ptr_detach (UNIT *uptr)
{
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
SETBIT(ptr_dsw, PTR1134_DSW_READER_NOT_READY);
return detach_unit(uptr);
return detach_unit(uptr);
}
/* ptr_attach - perform paper tape initial program load */
static t_stat ptr_boot (int32 unitno, DEVICE *dptr)
{
int ch, nch, val, addr;
t_bool leader = TRUE, start = FALSE;
t_stat rval;
int ch, nch, val, addr;
t_bool leader = TRUE, start = FALSE;
t_stat rval;
addr = 0;
nch = 0;
val = 0;
addr = 0;
nch = 0;
val = 0;
for (;;) {
if ((ch = getc(ptr_unit->fileref)) == EOF) {
printf("EOF on paper tape without finding Channel 5 end-of-load mark\n");
break;
}
for (;;) {
if ((ch = getc(ptr_unit->fileref)) == EOF) {
printf("EOF on paper tape without finding Channel 5 end-of-load mark\n");
break;
}
if (leader) {
if ((ch & 0x7F) == 0x7F) /* ignore leading rubouts or "delete" characters */
continue;
if (leader) {
if ((ch & 0x7F) == 0x7F) /* ignore leading rubouts or "delete" characters */
continue;
leader = FALSE; /* after first nonrubout, any punch in channel 5 terminates load */
}
leader = FALSE; /* after first nonrubout, any punch in channel 5 terminates load */
}
/* this is untested -- not sure of actual byte ordering */
/* this is untested -- not sure of actual byte ordering */
val = (val << 4) | (ch & 0x0F); /* get next nybble */
val = (val << 4) | (ch & 0x0F); /* get next nybble */
if (++nch == 4) { /* if we now have four nybbles, store the word */
M[addr & mem_mask] = (uint16) val;
if (++nch == 4) { /* if we now have four nybbles, store the word */
M[addr & mem_mask] = (uint16) val;
addr++; /* prepare for next word */
nch = 0;
val = 0;
}
addr++; /* prepare for next word */
nch = 0;
val = 0;
}
if (ch & 0x10) { /* channel 5 punch terminates load */
start = TRUE;
break;
}
}
if (ch & 0x10) { /* channel 5 punch terminates load */
start = TRUE;
break;
}
}
if (! start) /* if we didn't get a valid load, report EOF error */
return SCPE_EOF;
if (! start) /* if we didn't get a valid load, report EOF error */
return SCPE_EOF;
if ((rval = reset_all(0)) != SCPE_OK) /* force a reset */
return rval;
if ((rval = reset_all(0)) != SCPE_OK) /* force a reset */
return rval;
IAR = 0; /* start running at address 0 */
return SCPE_OK;
IAR = 0; /* start running at address 0 */
return SCPE_OK;
}
/* ptp_attach - attach file to simulated paper tape punch */
static t_stat ptp_attach (UNIT *uptr, CONST char *cptr)
{
t_stat rval;
t_stat rval;
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY); /* assume failure */
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY); /* assume failure */
if ((rval = attach_unit(uptr, cptr)) != SCPE_OK) /* use standard attach */
return rval;
if ((rval = attach_unit(uptr, cptr)) != SCPE_OK) /* use standard attach */
return rval;
fseek(uptr->fileref, 0, SEEK_END); /* if we opened an existing file, append to it */
uptr->pos = ftell(uptr->fileref);
fseek(uptr->fileref, 0, SEEK_END); /* if we opened an existing file, append to it */
uptr->pos = ftell(uptr->fileref);
if ((ptr_dsw & PTR1134_DSW_PUNCH_BUSY) == 0)
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY); /* we're in business */
if ((ptr_dsw & PTR1134_DSW_PUNCH_BUSY) == 0)
CLRBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY); /* we're in business */
return SCPE_OK;
return SCPE_OK;
}
/* ptp_detach - detach file from simulated paper tape punch */
static t_stat ptp_detach (UNIT *uptr)
{
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
SETBIT(ptr_dsw, PTR1134_DSW_PUNCH_NOT_READY);
return detach_unit(uptr);
return detach_unit(uptr);
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,12 +5,12 @@
Revision History
0.27 2005Mar08 - Added sca device
0.26 2002Apr24 - Added !BREAK in card deck file to stop simulator
0.25 2002Apr18 - Fixed some card reader problems. It starts the reader
properly if you attach a deck while it's waiting to a read.
0.25 2002Apr18 - Fixed some card reader problems. It starts the reader
properly if you attach a deck while it's waiting to a read.
0.24 2002Mar27 - Fixed BOSC bug; BOSC works in short instructions too
0.23 2002Feb26 - Added @decklist feature for ATTACH CR.
0.22 2002Feb26 - Replaced "strupr" with "upcase" for compatibility.
0.21 2002Feb25 - Some compiler compatibiity changes, couple of compiler-detected
0.21 2002Feb25 - Some compiler compatibiity changes, couple of compiler-detected
bugs
0.01 2001Jul31 - Derived from pdp11_sys.c, which carries this disclaimer:
@ -39,12 +39,12 @@ extern t_bool is_1800;
/* SCP data structures and interface routines
sim_name simulator name string
sim_PC pointer to saved PC register descriptor
sim_emax number of words for examine
sim_devices array of pointers to simulated devices
sim_stop_messages array of pointers to stop messages
sim_load binary loader
sim_name simulator name string
sim_PC pointer to saved PC register descriptor
sim_emax number of words for examine
sim_devices array of pointers to simulated devices
sim_stop_messages array of pointers to stop messages
sim_load binary loader
*/
char sim_name[] = "IBM 1130";
@ -54,38 +54,38 @@ REG *sim_PC = &cpu_reg[0];
int32 sim_emax = 4;
DEVICE *sim_devices[] = {
&cpu_dev, /* the cpu */
&dsk_dev, /* disk drive(s) */
&cr_dev, /* card reader/punch */
&cp_dev,
&tti_dev, /* console keyboard, selectric printer */
&tto_dev,
&prt_dev, /* 1132 printer */
&ptr_dev, /* 1134 paper tape reader */
&ptp_dev, /* 1055 paper tape punch */
&sca_dev, /* Synchronous communications adapter option */
&console_dev, /* console display (windows GUI) */
&gdu_dev, /* 2250 display */
&t2741_dev, /* nonstandard serial interface used by APL\1130 */
&plot_dev, /* plotter device, in ibm1130_plot.c */
NULL
&cpu_dev, /* the cpu */
&dsk_dev, /* disk drive(s) */
&cr_dev, /* card reader/punch */
&cp_dev,
&tti_dev, /* console keyboard, selectric printer */
&tto_dev,
&prt_dev, /* 1132 printer */
&ptr_dev, /* 1134 paper tape reader */
&ptp_dev, /* 1055 paper tape punch */
&sca_dev, /* Synchronous communications adapter option */
&console_dev, /* console display (windows GUI) */
&gdu_dev, /* 2250 display */
&t2741_dev, /* nonstandard serial interface used by APL\1130 */
&plot_dev, /* plotter device, in ibm1130_plot.c */
NULL
};
const char *sim_stop_messages[] = {
"Unknown error",
"Wait",
"Invalid command",
"Simulator breakpoint",
"Use of incomplete simulator function",
"Power off",
"!BREAK in card deck file",
"Phase load break",
"Program has run amok",
"Run time limit exceeded",
"Immediate Stop key requested",
"Simulator break key pressed",
"Simulator step count expired",
"Simulator IO error",
"Unknown error",
"Wait",
"Invalid command",
"Simulator breakpoint",
"Use of incomplete simulator function",
"Power off",
"!BREAK in card deck file",
"Phase load break",
"Program has run amok",
"Run time limit exceeded",
"Immediate Stop key requested",
"Simulator break key pressed",
"Simulator step count expired",
"Simulator IO error",
};
/* Loader. IPL is normally performed by card reader (boot command). This function
@ -93,13 +93,13 @@ const char *sim_stop_messages[] = {
*
* blank lines or lines starting with ; / or # are ignored as comments
*
* @XXXX set load addresss to hex value XXXX
* XXXX store hex word value XXXX at current load address and increment address
* @XXXX set load addresss to hex value XXXX
* XXXX store hex word value XXXX at current load address and increment address
* ...
* =XXXX set IAR to hex value XXXX
* ZXXXX zero XXXX words and increment load address
* SXXXX set console entry switches to XXXX. This lets a program specify the
* default value for the toggle switches.
* =XXXX set IAR to hex value XXXX
* ZXXXX zero XXXX words and increment load address
* SXXXX set console entry switches to XXXX. This lets a program specify the
* default value for the toggle switches.
*
* Multiple @ and data sections may be entered. If more than one = or S value is specified
* the last one wins.
@ -111,154 +111,154 @@ const char *sim_stop_messages[] = {
t_stat my_load (FILE *fileref, const char *cptr, const char *fnam)
{
char line[150], *c;
int iaddr = -1, runaddr = -1, val, nwords;
char line[150], *c;
int iaddr = -1, runaddr = -1, val, nwords;
while (fgets(line, sizeof(line), fileref) != NULL) {
for (c = line; *c && *c <= ' '; c++) /* find first nonblank */
;
while (fgets(line, sizeof(line), fileref) != NULL) {
for (c = line; *c && *c <= ' '; c++) /* find first nonblank */
;
if (*c == '\0' || *c == '#' || *c == '/' || *c == ';')
continue; /* empty line or comment */
if (*c == '\0' || *c == '#' || *c == '/' || *c == ';')
continue; /* empty line or comment */
if (*c == '@') { /* set load address */
if (sscanf(c+1, "%x", &iaddr) != 1)
return SCPE_FMT;
}
else if (*c == '=') {
if (sscanf(c+1, "%x", &runaddr) != 1)
return SCPE_FMT;
}
else if (*c == 's' || *c == 'S') {
if (sscanf(c+1, "%x", &val) != 1)
return SCPE_FMT;
if (*c == '@') { /* set load address */
if (sscanf(c+1, "%x", &iaddr) != 1)
return SCPE_FMT;
}
else if (*c == '=') {
if (sscanf(c+1, "%x", &runaddr) != 1)
return SCPE_FMT;
}
else if (*c == 's' || *c == 'S') {
if (sscanf(c+1, "%x", &val) != 1)
return SCPE_FMT;
CES = val & 0xFFFF; /*preload console entry switches */
}
else if (*c == 'z' || *c == 'Z') {
if (sscanf(c+1, "%x", &nwords) != 1)
return SCPE_FMT;
CES = val & 0xFFFF; /*preload console entry switches */
}
else if (*c == 'z' || *c == 'Z') {
if (sscanf(c+1, "%x", &nwords) != 1)
return SCPE_FMT;
if (iaddr == -1)
return SCPE_FMT;
if (iaddr == -1)
return SCPE_FMT;
while (--nwords >= 0) {
WriteW(iaddr, 0);
iaddr++;
}
}
else if (strchr("0123456789abcdefABCDEF", *c) != NULL) {
if (sscanf(c, "%x", &val) != 1)
return SCPE_FMT;
while (--nwords >= 0) {
WriteW(iaddr, 0);
iaddr++;
}
}
else if (strchr("0123456789abcdefABCDEF", *c) != NULL) {
if (sscanf(c, "%x", &val) != 1)
return SCPE_FMT;
if (iaddr == -1)
return SCPE_FMT;
if (iaddr == -1)
return SCPE_FMT;
WriteW(iaddr, val); /*store data */
iaddr++;
}
else
return SCPE_FMT; /*unexpected data */
}
WriteW(iaddr, val); /*store data */
iaddr++;
}
else
return SCPE_FMT; /*unexpected data */
}
if (runaddr != -1)
IAR = runaddr;
if (runaddr != -1)
IAR = runaddr;
return SCPE_OK;
return SCPE_OK;
}
t_stat my_save (FILE *fileref, const char *cptr, const char *fnam)
{
int iaddr, nzeroes = 0, nwords = (int) (MEMSIZE/2), val;
int iaddr, nzeroes = 0, nwords = (int) (MEMSIZE/2), val;
fprintf(fileref, "=%04x\r\n", IAR);
fprintf(fileref, "@0000\r\n");
for (iaddr = 0; iaddr < nwords; iaddr++) {
val = ReadW(iaddr);
if (val == 0) /*queue up zeroes */
nzeroes++;
else {
if (nzeroes >= 4) { /*spit out a Z directive */
fprintf(fileref, "Z%04x\r\n", nzeroes);
nzeroes = 0;
}
else { /*write queued zeroes literally */
while (nzeroes > 0) {
fprintf(fileref, " 0000\r\n");
nzeroes--;
}
}
fprintf(fileref, " %04x\r\n", val);
}
}
if (nzeroes >= 4) { /*emit any queued zeroes */
fprintf(fileref, "Z%04x\r\n", nzeroes);
nzeroes = 0;
}
else {
while (nzeroes > 0) {
fprintf(fileref, " 0000\r\n");
nzeroes--;
}
}
fprintf(fileref, "=%04x\r\n", IAR);
fprintf(fileref, "@0000\r\n");
for (iaddr = 0; iaddr < nwords; iaddr++) {
val = ReadW(iaddr);
if (val == 0) /*queue up zeroes */
nzeroes++;
else {
if (nzeroes >= 4) { /*spit out a Z directive */
fprintf(fileref, "Z%04x\r\n", nzeroes);
nzeroes = 0;
}
else { /*write queued zeroes literally */
while (nzeroes > 0) {
fprintf(fileref, " 0000\r\n");
nzeroes--;
}
}
fprintf(fileref, " %04x\r\n", val);
}
}
if (nzeroes >= 4) { /*emit any queued zeroes */
fprintf(fileref, "Z%04x\r\n", nzeroes);
nzeroes = 0;
}
else {
while (nzeroes > 0) {
fprintf(fileref, " 0000\r\n");
nzeroes--;
}
}
return SCPE_OK;
return SCPE_OK;
}
t_stat sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
{
if (flag)
return my_save(fileref, cptr, fnam);
else
return my_load(fileref, cptr, fnam);
if (flag)
return my_save(fileref, cptr, fnam);
else
return my_load(fileref, cptr, fnam);
}
/* Specifier decode
Inputs:
*of = output stream
addr = current PC
spec = specifier
nval = next word
flag = TRUE if decoding for CPU
iflag = TRUE if decoding integer instruction
*of = output stream
addr = current PC
spec = specifier
nval = next word
flag = TRUE if decoding for CPU
iflag = TRUE if decoding integer instruction
Outputs:
count = -number of extra words retired
count = -number of extra words retired
*/
/* Symbolic decode
Inputs:
*of = output stream
addr = current PC
*val = values to decode
*uptr = pointer to unit
sw = switches
*of = output stream
addr = current PC
*val = values to decode
*uptr = pointer to unit
sw = switches
Outputs:
return = if >= 0, error code
if < 0, number of extra words retired
return = if >= 0, error code
if < 0, number of extra words retired
*/
static const char *opcode[] = {
"?00 ", "XIO ", "SLA ", "SRA ",
"LDS ", "STS ", "WAIT", "?07 ",
"BSI ", "BSC ", "?0A ", "?0B ",
"LDX ", "STX ", "MDX ", "?0F ",
"A ", "AD ", "S ", "SD ",
"M ", "D ", "?16 ", "?17 ",
"LD ", "LDD ", "STO ", "STD ",
"AND ", "OR ", "EOR ", "?1F ",
"?00 ", "XIO ", "SLA ", "SRA ",
"LDS ", "STS ", "WAIT", "?07 ",
"BSI ", "BSC ", "?0A ", "?0B ",
"LDX ", "STX ", "MDX ", "?0F ",
"A ", "AD ", "S ", "SD ",
"M ", "D ", "?16 ", "?17 ",
"LD ", "LDD ", "STO ", "STD ",
"AND ", "OR ", "EOR ", "?1F ",
};
static char relative[] = { /*true if short mode displacements are IAR relative */
FALSE, TRUE, FALSE, FALSE,
FALSE, TRUE, FALSE, FALSE,
TRUE, FALSE, FALSE, FALSE,
TRUE, TRUE, TRUE, FALSE,
TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, FALSE, FALSE,
TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, FALSE
static char relative[] = { /*true if short mode displacements are IAR relative */
FALSE, TRUE, FALSE, FALSE,
FALSE, TRUE, FALSE, FALSE,
TRUE, FALSE, FALSE, FALSE,
TRUE, TRUE, TRUE, FALSE,
TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, FALSE, FALSE,
TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, FALSE
};
static const char *lsopcode[] = {"SLA ", "SLCA ", "SLT ", "SLC "};
@ -267,133 +267,133 @@ static const char tagc[] = " 123";
static 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,
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,
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,
};
static int ebcdic_to_ascii (int ch)
{
int j;
int j;
for (j = 32; j < 128; j++)
if (ascii_to_ebcdic_table[j] == ch)
return j;
for (j = 32; j < 128; j++)
if (ascii_to_ebcdic_table[j] == ch)
return j;
return '?';
return '?';
}
t_stat fprint_sym (FILE *of, t_addr addr, t_value *val, UNIT *uptr, int32 sw)
{
int32 ch, OP, F, TAG, INDIR, DSPLC, IR, eaddr;
const char *mnem;
int32 ch, OP, F, TAG, INDIR, DSPLC, IR, eaddr;
const char *mnem;
char tst[12];
/* if (sw & SWMASK ('A')) { // ASCII? not useful
fprintf (of, (c1 < 040)? "<%03o>": "%c", c1);
return SCPE_OK;
}
/* if (sw & SWMASK ('A')) { // ASCII? not useful
fprintf (of, (c1 < 040)? "<%03o>": "%c", c1);
return SCPE_OK;
}
*/
if (sw & SWMASK ('C')) /* character? not useful -- make it EBCDIC */
sw |= SWMASK('E');
if (sw & SWMASK ('C')) /* character? not useful -- make it EBCDIC */
sw |= SWMASK('E');
if (sw & SWMASK ('E')) { /* EBCDIC! */
ch = ebcdic_to_ascii((val[0] >> 8) & 0xFF); /* take high byte first */
fprintf (of, (ch < ' ')? "<%03o>": "%c", ch);
ch = ebcdic_to_ascii(val[0] & 0xFF);
fprintf (of, (ch < ' ')? "<%03o>": "%c", ch);
return SCPE_OK;
}
if (sw & SWMASK ('E')) { /* EBCDIC! */
ch = ebcdic_to_ascii((val[0] >> 8) & 0xFF); /* take high byte first */
fprintf (of, (ch < ' ')? "<%03o>": "%c", ch);
ch = ebcdic_to_ascii(val[0] & 0xFF);
fprintf (of, (ch < ' ')? "<%03o>": "%c", ch);
return SCPE_OK;
}
if (sw & SWMASK ('H')) { /* HOLLERITH! now THIS is useful! */
ch = hollerith_to_ascii((int16) val[0]);
fprintf (of, (ch < ' ')? "<%03o>": "%c", ch);
return SCPE_OK;
}
if (sw & SWMASK ('H')) { /* HOLLERITH! now THIS is useful! */
ch = hollerith_to_ascii((int16) val[0]);
fprintf (of, (ch < ' ')? "<%03o>": "%c", ch);
return SCPE_OK;
}
if (! (sw & SWMASK ('M')))
return SCPE_ARG;
if (! (sw & SWMASK ('M')))
return SCPE_ARG;
IR = val[0];
OP = (IR >> 11) & 0x1F; /* opcode */
F = IR & 0x0400; /* format bit: 1 = long instr */
TAG = IR & 0x0300; /* tag bits: index reg select */
if (TAG)
TAG >>= 8;
IR = val[0];
OP = (IR >> 11) & 0x1F; /* opcode */
F = IR & 0x0400; /* format bit: 1 = long instr */
TAG = IR & 0x0300; /* tag bits: index reg select */
if (TAG)
TAG >>= 8;
if (F) { /* long instruction, ASSUME it's valid (have to decrement IAR if not) */
INDIR = IR & 0x0080; /* indirect bit */
DSPLC = IR & 0x007F; /* displacement or modifier */
if (DSPLC & 0x0040)
DSPLC |= ~ 0x7F; /* sign extend */
if (F) { /* long instruction, ASSUME it's valid (have to decrement IAR if not) */
INDIR = IR & 0x0080; /* indirect bit */
DSPLC = IR & 0x007F; /* displacement or modifier */
if (DSPLC & 0x0040)
DSPLC |= ~ 0x7F; /* sign extend */
eaddr = val[1]; /* get reference address */
}
else { /* short instruction, use displacement */
INDIR = 0; /* never indirect */
DSPLC = IR & 0x00FF; /* get displacement */
if (DSPLC & 0x0080)
DSPLC |= ~ 0xFF;
eaddr = val[1]; /* get reference address */
}
else { /* short instruction, use displacement */
INDIR = 0; /* never indirect */
DSPLC = IR & 0x00FF; /* get displacement */
if (DSPLC & 0x0080)
DSPLC |= ~ 0xFF;
eaddr = DSPLC;
if (relative[OP] && ! TAG)
eaddr += addr+1; /* turn displacement into address */
}
eaddr = DSPLC;
if (relative[OP] && ! TAG)
eaddr += addr+1; /* turn displacement into address */
}
mnem = opcode[OP]; /* get mnemonic */
if (is_1800) { /* these two are defined on the 1800 but undefined on the 1130 */
if (OP == 0x16)
mnem = "CMP ";
else if (OP == 0x17)
mnem = "DCMP";
}
mnem = opcode[OP]; /* get mnemonic */
if (is_1800) { /* these two are defined on the 1800 but undefined on the 1130 */
if (OP == 0x16)
mnem = "CMP ";
else if (OP == 0x17)
mnem = "DCMP";
}
if (OP == 0x02) { /* left shifts are special */
mnem = lsopcode[(DSPLC >> 6) & 0x0003];
DSPLC &= 0x003F;
eaddr = DSPLC;
}
else if (OP == 0x03) { /* right shifts too */
mnem = rsopcode[(DSPLC >> 6) & 0x0003];
DSPLC &= 0x003F;
eaddr = DSPLC;
}
else if ((OP == 0x08 && F)|| OP == 0x09) { /* BSI L and BSC any */
if (OP == 0x09 && (IR & 0x40))
mnem = "BOSC";
if (OP == 0x02) { /* left shifts are special */
mnem = lsopcode[(DSPLC >> 6) & 0x0003];
DSPLC &= 0x003F;
eaddr = DSPLC;
}
else if (OP == 0x03) { /* right shifts too */
mnem = rsopcode[(DSPLC >> 6) & 0x0003];
DSPLC &= 0x003F;
eaddr = DSPLC;
}
else if ((OP == 0x08 && F)|| OP == 0x09) { /* BSI L and BSC any */
if (OP == 0x09 && (IR & 0x40))
mnem = "BOSC";
tst[0] = '\0';
if (DSPLC & 0x20) strcat(tst, "Z");
if (DSPLC & 0x10) strcat(tst, "-");
if (DSPLC & 0x08) strcat(tst, "+");
if (DSPLC & 0x04) strcat(tst, "E");
if (DSPLC & 0x02) strcat(tst, "C");
if (DSPLC & 0x01) strcat(tst, "O");
tst[0] = '\0';
if (DSPLC & 0x20) strcat(tst, "Z");
if (DSPLC & 0x10) strcat(tst, "-");
if (DSPLC & 0x08) strcat(tst, "+");
if (DSPLC & 0x04) strcat(tst, "E");
if (DSPLC & 0x02) strcat(tst, "C");
if (DSPLC & 0x01) strcat(tst, "O");
if (F) {
fprintf(of, "%04x %s %c%c %s,%04x ", IR & 0xFFFF, mnem, F ? (INDIR ? 'I' : 'L') : ' ', tagc[TAG], tst, eaddr & 0xFFFF);
return -1;
}
fprintf(of, "%04x %s %c%c %s ", IR & 0xFFFF, mnem, F ? (INDIR ? 'I' : 'L') : ' ', tagc[TAG], tst);
return SCPE_OK;
}
else if (OP == 0x0e && TAG == 0) { /* MDX with no tag => MDM or jump */
if (F) {
fprintf(of, "%04x %s %c%c %04x,%x (%d) ", IR & 0xFFFF, "MDM ", (INDIR ? 'I' : 'L'), tagc[TAG], eaddr & 0xFFFF, DSPLC & 0xFFFF, DSPLC);
return -1;
}
mnem = "JMP ";
}
if (F) {
fprintf(of, "%04x %s %c%c %s,%04x ", IR & 0xFFFF, mnem, F ? (INDIR ? 'I' : 'L') : ' ', tagc[TAG], tst, eaddr & 0xFFFF);
return -1;
}
fprintf(of, "%04x %s %c%c %s ", IR & 0xFFFF, mnem, F ? (INDIR ? 'I' : 'L') : ' ', tagc[TAG], tst);
return SCPE_OK;
}
else if (OP == 0x0e && TAG == 0) { /* MDX with no tag => MDM or jump */
if (F) {
fprintf(of, "%04x %s %c%c %04x,%x (%d) ", IR & 0xFFFF, "MDM ", (INDIR ? 'I' : 'L'), tagc[TAG], eaddr & 0xFFFF, DSPLC & 0xFFFF, DSPLC);
return -1;
}
mnem = "JMP ";
}
fprintf(of, "%04x %s %c%c %04x ", IR & 0xFFFF, mnem, F ? (INDIR ? 'I' : 'L') : ' ', tagc[TAG], eaddr & 0xFFFF);
return F ? -1 : SCPE_OK; /* inform how many words we read */
fprintf(of, "%04x %s %c%c %04x ", IR & 0xFFFF, mnem, F ? (INDIR ? 'I' : 'L') : ' ', tagc[TAG], eaddr & 0xFFFF);
return F ? -1 : SCPE_OK; /* inform how many words we read */
}
int32 get_reg (char *cptr, const char *strings[], char mchar)
@ -404,111 +404,111 @@ return -1;
/* Number or memory address
Inputs:
*cptr = pointer to input string
*dptr = pointer to output displacement
*pflag = pointer to accumulating flags
*cptr = pointer to input string
*dptr = pointer to output displacement
*pflag = pointer to accumulating flags
Outputs:
cptr = pointer to next character in input string
NULL if parsing error
cptr = pointer to next character in input string
NULL if parsing error
Flags: 0 (no result), A_NUM (number), A_REL (relative)
*/
char *get_addr (char *cptr, int32 *dptr, int32 *pflag)
{
return 0;
return 0;
}
/* Specifier decode
Inputs:
*cptr = pointer to input string
addr = current PC
n1 = 0 if no extra word used
-1 if extra word used in prior decode
*sptr = pointer to output specifier
*dptr = pointer to output displacement
cflag = true if parsing for the CPU
iflag = true if integer specifier
*cptr = pointer to input string
addr = current PC
n1 = 0 if no extra word used
-1 if extra word used in prior decode
*sptr = pointer to output specifier
*dptr = pointer to output displacement
cflag = true if parsing for the CPU
iflag = true if integer specifier
Outputs:
status = = -1 extra word decoded
= 0 ok
= +1 error
status = = -1 extra word decoded
= 0 ok
= +1 error
*/
t_stat get_spec (char *cptr, t_addr addr, int32 n1, int32 *sptr, t_value *dptr,
int32 cflag, int32 iflag)
int32 cflag, int32 iflag)
{
return -1;
return -1;
}
/* Symbolic input
Inputs:
*cptr = pointer to input string
addr = current PC
*uptr = pointer to unit
*val = pointer to output values
sw = switches
*cptr = pointer to input string
addr = current PC
*uptr = pointer to unit
*val = pointer to output values
sw = switches
Outputs:
status = > 0 error code
<= 0 -number of extra words
status = > 0 error code
<= 0 -number of extra words
*/
t_stat parse_sym (CONST char *cptr, t_addr addr, UNIT *uptr, t_value *val, int32 sw)
{
return SCPE_ARG;
return SCPE_ARG;
}
#ifndef _WIN32
int strnicmp (const char *a, const char *b, size_t n)
{
int ca, cb;
int ca, cb;
if (n == 0) return 0; /* zero length compare is equal */
if (n == 0) return 0; /* zero length compare is equal */
for (;;) {
if ((ca = *a) == 0) /* get character, stop on null terminator */
return *b ? -1 : 0;
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;
if (ca >= 'a' && ca <= 'z') /* fold lowercase to uppercase */
ca -= 32;
cb = *b;
if (cb >= 'a' && cb <= 'z')
cb -= 32;
cb = *b;
if (cb >= 'a' && cb <= 'z')
cb -= 32;
if ((ca -= cb) != 0) /* if different, return comparison */
return ca;
if ((ca -= cb) != 0) /* if different, return comparison */
return ca;
a++, b++;
a++, b++;
if (--n == 0) /* still equal after n characters? quit now */
return 0;
}
if (--n == 0) /* still equal after n characters? quit now */
return 0;
}
}
int strcmpi (const char *a, const char *b)
{
int ca, cb;
int ca, cb;
for (;;) {
if ((ca = *a) == 0) /* get character, stop on null terminator */
return *b ? -1 : 0;
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;
if (ca >= 'a' && ca <= 'z') /* fold lowercase to uppercase */
ca -= 32;
cb = *b;
if (cb >= 'a' && cb <= 'z')
cb -= 32;
cb = *b;
if (cb >= 'a' && cb <= 'z')
cb -= 32;
if ((ca -= cb) != 0) /* if different, return comparison */
return ca;
if ((ca -= cb) != 0) /* if different, return comparison */
return ca;
a++, b++;
}
a++, b++;
}
}
#endif

View file

@ -9,34 +9,34 @@
#define DEBUG_T2741
static TMLN t2741_ldsc = { 0 }; /* line descr for telnet attachment */
static TMXR t2741_tmxr = { 1, 0, 0, &t2741_ldsc }; /* line mux for telnet attachment */
static TMLN t2741_ldsc = { 0 }; /* line descr for telnet attachment */
static TMXR t2741_tmxr = { 1, 0, 0, &t2741_ldsc }; /* line mux for telnet attachment */
#define T2741_DSW_TRANSMIT_NOT_READY 0x4000
#define T2741_DSW_READ_RESPONSE 0x1000
#define T2741_DSW_READ_OVERRUN 0x0800
#define T2741_DSW_ATTENTION 0x0010
#define T2741_DSW_TRANSMIT_NOT_READY 0x4000
#define T2741_DSW_READ_RESPONSE 0x1000
#define T2741_DSW_READ_OVERRUN 0x0800
#define T2741_DSW_ATTENTION 0x0010
#define IS_ONLINE(u) (((u)->flags & (UNIT_ATT|UNIT_DIS)) == UNIT_ATT)
#define UNIT_V_PHYSICAL_TERM (UNIT_V_UF + 0) /* indicates not telnet but attachment to real terminal */
#define UNIT_V_UPCASE (UNIT_V_UF + 1) /* indicates upshift performed */
#define UNIT_V_SENDING (UNIT_V_UF + 2) /* indicates not telnet but attachment to real terminal */
#define UNIT_V_RECEIVING (UNIT_V_UF + 3) /* indicates not telnet but attachment to real terminal */
#define UNIT_V_PHYSICAL_TERM (UNIT_V_UF + 0) /* indicates not telnet but attachment to real terminal */
#define UNIT_V_UPCASE (UNIT_V_UF + 1) /* indicates upshift performed */
#define UNIT_V_SENDING (UNIT_V_UF + 2) /* indicates not telnet but attachment to real terminal */
#define UNIT_V_RECEIVING (UNIT_V_UF + 3) /* indicates not telnet but attachment to real terminal */
#define UNIT_PHYSICAL_TERM (1u << UNIT_V_PHYSICAL_TERM)
#define UNIT_UPCASE (1u << UNIT_V_UPCASE)
#define UNIT_SENDING (1u << UNIT_V_SENDING)
#define UNIT_RECEIVING (1u << UNIT_V_RECEIVING)
#define UNIT_PHYSICAL_TERM (1u << UNIT_V_PHYSICAL_TERM)
#define UNIT_UPCASE (1u << UNIT_V_UPCASE)
#define UNIT_SENDING (1u << UNIT_V_SENDING)
#define UNIT_RECEIVING (1u << UNIT_V_RECEIVING)
#define CODE_SHIFTUP 0x1C00
#define CODE_SHIFTDOWN 0x7C00
#define CODE_CIRCLEC 0x1F00
#define CODE_CIRCLED 0x1600
#define CODE_RETURN 0x5B00
#define CODE_LINEFEED 0x3B00
#define CODE_ATTENTION 0x0001 /* pseudocode, never really returned as a received character */
#define CODE_UNKNOWN 0x0000
#define CODE_SHIFTUP 0x1C00
#define CODE_SHIFTDOWN 0x7C00
#define CODE_CIRCLEC 0x1F00
#define CODE_CIRCLED 0x1600
#define CODE_RETURN 0x5B00
#define CODE_LINEFEED 0x3B00
#define CODE_ATTENTION 0x0001 /* pseudocode, never really returned as a received character */
#define CODE_UNKNOWN 0x0000
static t_stat t2741_svc (UNIT *uptr);
static t_stat t2741_reset (DEVICE *dptr);
@ -46,343 +46,343 @@ static uint16 ascii_to_t2741 (int ascii);
static const char * t2741_to_ascii (uint16 code);
static void set_transmit_notready (void);
static uint16 t2741_dsw = T2741_DSW_TRANSMIT_NOT_READY; /* device status word */
static uint32 t2741_swait = 200; /* character send wait */
static uint32 t2741_rwait = 2000; /* character receive wait */
static uint16 t2741_char = 0; /* last character received */
static int overrun = FALSE;
static uint16 t2741_dsw = T2741_DSW_TRANSMIT_NOT_READY; /* device status word */
static uint32 t2741_swait = 200; /* character send wait */
static uint32 t2741_rwait = 2000; /* character receive wait */
static uint16 t2741_char = 0; /* last character received */
static int overrun = FALSE;
static uint32 t2741_socket = 1130;
UNIT t2741_unit[1] = {
{ UDATA (&t2741_svc, UNIT_ATTABLE, 0) },
{ UDATA (&t2741_svc, UNIT_ATTABLE, 0) },
};
REG t2741_reg[] = {
{ HRDATA (DSW, t2741_dsw, 16) }, /* device status word */
{ DRDATA (RTIME, t2741_rwait, 24), PV_LEFT }, /* character receive wait */
{ DRDATA (STIME, t2741_swait, 24), PV_LEFT }, /* character send wait */
{ DRDATA (SOCKET, t2741_socket,16), PV_LEFT }, /* socket number */
{ HRDATA (LASTCHAR, t2741_char, 16), PV_LEFT }, /* last character read */
{ NULL } };
{ HRDATA (DSW, t2741_dsw, 16) }, /* device status word */
{ DRDATA (RTIME, t2741_rwait, 24), PV_LEFT }, /* character receive wait */
{ DRDATA (STIME, t2741_swait, 24), PV_LEFT }, /* character send wait */
{ DRDATA (SOCKET, t2741_socket,16), PV_LEFT }, /* socket number */
{ HRDATA (LASTCHAR, t2741_char, 16), PV_LEFT }, /* last character read */
{ NULL } };
DEVICE t2741_dev = {
"T2741", t2741_unit, t2741_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, t2741_reset,
NULL, t2741_attach, t2741_detach};
"T2741", t2741_unit, t2741_reg, NULL,
1, 16, 16, 1, 16, 16,
NULL, NULL, t2741_reset,
NULL, t2741_attach, t2741_detach};
/* xio_t2741_terminal - XIO command interpreter for the terminal adapter */
void xio_t2741_terminal (int32 iocc_addr, int32 iocc_func, int32 iocc_mod)
{
char msg[80];
uint16 code;
char msg[80];
uint16 code;
switch (iocc_func) {
case XIO_READ: /* read: return last character read */
code = t2741_char & 0xFF00;
M[iocc_addr & mem_mask] = code;
overrun = FALSE;
switch (iocc_func) {
case XIO_READ: /* read: return last character read */
code = t2741_char & 0xFF00;
M[iocc_addr & mem_mask] = code;
overrun = FALSE;
#ifdef DEBUG_T2741
/* trace_both("T2741 %04x READ %02x %s", prev_IAR, code >> 8, t2741_to_ascii(code)); */
/* trace_both("T2741 %04x READ %02x %s", prev_IAR, code >> 8, t2741_to_ascii(code)); */
#endif
break;
break;
case XIO_WRITE: /* write: initiate character send */
code = M[iocc_addr & mem_mask] & 0xFF00;
case XIO_WRITE: /* write: initiate character send */
code = M[iocc_addr & mem_mask] & 0xFF00;
#ifdef DEBUG_T2741
trace_both("T2741 %04x SEND %02x %s", prev_IAR, code >> 8, t2741_to_ascii(code));
trace_both("T2741 %04x SEND %02x %s", prev_IAR, code >> 8, t2741_to_ascii(code));
#endif
SETBIT(t2741_dsw, T2741_DSW_TRANSMIT_NOT_READY);
SETBIT(t2741_unit->flags, UNIT_SENDING);
SETBIT(t2741_dsw, T2741_DSW_TRANSMIT_NOT_READY);
SETBIT(t2741_unit->flags, UNIT_SENDING);
if (code == CODE_SHIFTUP)
SETBIT(t2741_unit->flags, UNIT_UPCASE);
else if (code == CODE_SHIFTDOWN)
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
if (code == CODE_SHIFTUP)
SETBIT(t2741_unit->flags, UNIT_UPCASE);
else if (code == CODE_SHIFTDOWN)
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
sim_activate(t2741_unit, t2741_swait); /* schedule interrupt */
break;
sim_activate(t2741_unit, t2741_swait); /* schedule interrupt */
break;
case XIO_SENSE_DEV: /* sense device status */
ACC = t2741_dsw;
case XIO_SENSE_DEV: /* sense device status */
ACC = t2741_dsw;
#ifdef DEBUG_T2741
/* trace_both("T2741 %04x SENS %04x%s", prev_IAR, t2741_dsw, (iocc_mod & 0x01) ? " reset" : ""); */
/* trace_both("T2741 %04x SENS %04x%s", prev_IAR, t2741_dsw, (iocc_mod & 0x01) ? " reset" : ""); */
#endif
if (iocc_mod & 0x01) { /* reset interrupts */
CLRBIT(t2741_dsw, T2741_DSW_READ_RESPONSE);
CLRBIT(ILSW[4], ILSW_4_T2741_TERMINAL);
}
break;
if (iocc_mod & 0x01) { /* reset interrupts */
CLRBIT(t2741_dsw, T2741_DSW_READ_RESPONSE);
CLRBIT(ILSW[4], ILSW_4_T2741_TERMINAL);
}
break;
case XIO_CONTROL: /* control: do something to interface */
case XIO_CONTROL: /* control: do something to interface */
#ifdef DEBUG_T2741
trace_both("T2741 %04x CTRL %04x", prev_IAR, iocc_mod &0xFF);
trace_both("T2741 %04x CTRL %04x", prev_IAR, iocc_mod &0xFF);
#endif
SETBIT(t2741_unit->flags, UNIT_RECEIVING); /* set mode to receive mode */
if (IS_ONLINE(t2741_unit) && (t2741_char != 0 || ! feof(t2741_unit->fileref))) {
sim_activate(t2741_unit, t2741_rwait);
t2741_char = (CODE_CIRCLED >> 8); /* first character received after turnaround is circled */
}
break;
SETBIT(t2741_unit->flags, UNIT_RECEIVING); /* set mode to receive mode */
if (IS_ONLINE(t2741_unit) && (t2741_char != 0 || ! feof(t2741_unit->fileref))) {
sim_activate(t2741_unit, t2741_rwait);
t2741_char = (CODE_CIRCLED >> 8); /* first character received after turnaround is circled */
}
break;
default:
sprintf(msg, "Invalid T2741 XIO function %x", iocc_func);
xio_error(msg);
}
default:
sprintf(msg, "Invalid T2741 XIO function %x", iocc_func);
xio_error(msg);
}
}
static void set_transmit_notready (void)
{
if (IS_ONLINE(t2741_unit) && ! (t2741_unit->flags & UNIT_SENDING))
CLRBIT(t2741_dsw, T2741_DSW_TRANSMIT_NOT_READY);
else
SETBIT(t2741_dsw, T2741_DSW_TRANSMIT_NOT_READY);
if (IS_ONLINE(t2741_unit) && ! (t2741_unit->flags & UNIT_SENDING))
CLRBIT(t2741_dsw, T2741_DSW_TRANSMIT_NOT_READY);
else
SETBIT(t2741_dsw, T2741_DSW_TRANSMIT_NOT_READY);
}
static t_stat t2741_svc (UNIT *uptr)
{
int ch = EOF;
uint16 code;
int ch = EOF;
uint16 code;
if (uptr->flags & UNIT_SENDING) { /* xmit: no interrupt, as far as I know. just clr busy bit */
CLRBIT(uptr->flags, UNIT_SENDING);
set_transmit_notready();
}
if (uptr->flags & UNIT_SENDING) { /* xmit: no interrupt, as far as I know. just clr busy bit */
CLRBIT(uptr->flags, UNIT_SENDING);
set_transmit_notready();
}
if (uptr->flags & UNIT_RECEIVING) { /* rcv: fire interrupt */
t2741_char <<= 8;
if (uptr->flags & UNIT_RECEIVING) { /* rcv: fire interrupt */
t2741_char <<= 8;
if (t2741_char == 0) { /* there is no 2nd character from previous ascii input */
if ((ch = getc(t2741_unit->fileref)) == EOF)
t2741_char = 0;
else {
if (ch == '\r') { /* if we get CR, jump to LF */
if ((ch = getc(t2741_unit->fileref)) != '\n') {
ungetc(ch, t2741_unit->fileref);
ch = '\r';
}
}
if (t2741_char == 0) { /* there is no 2nd character from previous ascii input */
if ((ch = getc(t2741_unit->fileref)) == EOF)
t2741_char = 0;
else {
if (ch == '\r') { /* if we get CR, jump to LF */
if ((ch = getc(t2741_unit->fileref)) != '\n') {
ungetc(ch, t2741_unit->fileref);
ch = '\r';
}
}
if (ch == '\027') {
t2741_char = CODE_LINEFEED; /* attention key sends line feed character */
if (ch == '\027') {
t2741_char = CODE_LINEFEED; /* attention key sends line feed character */
#ifdef DEBUG_T2741
trace_both("T2741 ---- ATTENTION");
trace_both("T2741 ---- ATTENTION");
#endif
SETBIT(t2741_dsw, T2741_DSW_ATTENTION); /* no character returned ? */
}
else {
t2741_char = ascii_to_t2741(ch); /* translate to 2741 code(s) */
}
}
}
SETBIT(t2741_dsw, T2741_DSW_ATTENTION); /* no character returned ? */
}
else {
t2741_char = ascii_to_t2741(ch); /* translate to 2741 code(s) */
}
}
}
code = t2741_char & 0xFF00;
code = t2741_char & 0xFF00;
if (t2741_char != 0) {
if (overrun) /* previous character was not picked up! */
SETBIT(t2741_dsw, T2741_DSW_READ_OVERRUN);
if (t2741_char != 0) {
if (overrun) /* previous character was not picked up! */
SETBIT(t2741_dsw, T2741_DSW_READ_OVERRUN);
SETBIT(t2741_dsw, T2741_DSW_READ_RESPONSE);
SETBIT(ILSW[4], ILSW_4_T2741_TERMINAL); /* issue interrupt */
calc_ints();
SETBIT(t2741_dsw, T2741_DSW_READ_RESPONSE);
SETBIT(ILSW[4], ILSW_4_T2741_TERMINAL); /* issue interrupt */
calc_ints();
#ifdef DEBUG_T2741
trace_both("T2741 ---- RCVD %02x '%s' RDRESP%s%s", code >> 8, t2741_to_ascii(code),
(t2741_dsw & T2741_DSW_READ_OVERRUN) ? "|OVERRUN" : "",
(t2741_dsw & T2741_DSW_ATTENTION) ? "|ATTENTION" : "");
trace_both("T2741 ---- RCVD %02x '%s' RDRESP%s%s", code >> 8, t2741_to_ascii(code),
(t2741_dsw & T2741_DSW_READ_OVERRUN) ? "|OVERRUN" : "",
(t2741_dsw & T2741_DSW_ATTENTION) ? "|ATTENTION" : "");
#endif
overrun = TRUE; /* arm overrun flag */
}
overrun = TRUE; /* arm overrun flag */
}
if (t2741_char == CODE_CIRCLEC) /* end of line (CIRCLEC after RETURN) auto downshifts */
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
if (t2741_char == CODE_CIRCLEC) /* end of line (CIRCLEC after RETURN) auto downshifts */
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
if (t2741_char == 0 || code == CODE_CIRCLEC)
CLRBIT(uptr->flags, UNIT_RECEIVING); /* on enter or EOF, stop typing */
else
sim_activate(t2741_unit, t2741_rwait); /* schedule next character to arrive */
}
if (t2741_char == 0 || code == CODE_CIRCLEC)
CLRBIT(uptr->flags, UNIT_RECEIVING); /* on enter or EOF, stop typing */
else
sim_activate(t2741_unit, t2741_rwait); /* schedule next character to arrive */
}
return SCPE_OK;
return SCPE_OK;
}
static t_stat t2741_attach (UNIT *uptr, CONST char *cptr)
{
int rval;
int rval;
if ((rval = attach_unit(uptr, cptr)) == SCPE_OK) { /* use standard attach */
t2741_char = 0;
overrun = FALSE;
if ((rval = attach_unit(uptr, cptr)) == SCPE_OK) { /* use standard attach */
t2741_char = 0;
overrun = FALSE;
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
if ((t2741_unit->flags & UNIT_RECEIVING) && ! feof(t2741_unit->fileref))
sim_activate(t2741_unit, t2741_rwait); /* schedule interrupt */
}
if ((t2741_unit->flags & UNIT_RECEIVING) && ! feof(t2741_unit->fileref))
sim_activate(t2741_unit, t2741_rwait); /* schedule interrupt */
}
set_transmit_notready();
set_transmit_notready();
return rval;
return rval;
}
static t_stat t2741_detach (UNIT *uptr)
{
t_stat rval;
t_stat rval;
if (t2741_unit->flags & UNIT_RECEIVING) /* if receive was pending, cancel interrupt */
sim_cancel(t2741_unit);
if (t2741_unit->flags & UNIT_RECEIVING) /* if receive was pending, cancel interrupt */
sim_cancel(t2741_unit);
t2741_char = 0;
overrun = FALSE;
t2741_char = 0;
overrun = FALSE;
rval = detach_unit(uptr); /* use standard detach */
rval = detach_unit(uptr); /* use standard detach */
set_transmit_notready();
set_transmit_notready();
return rval;
return rval;
}
static t_stat t2741_reset (DEVICE *dptr)
{
sim_cancel(t2741_unit);
sim_cancel(t2741_unit);
CLRBIT(t2741_unit->flags, UNIT_SENDING|UNIT_RECEIVING|UNIT_UPCASE);
CLRBIT(t2741_unit->flags, UNIT_SENDING|UNIT_RECEIVING|UNIT_UPCASE);
t2741_char = 0;
t2741_dsw = 0;
overrun = FALSE;
t2741_char = 0;
t2741_dsw = 0;
overrun = FALSE;
set_transmit_notready();
set_transmit_notready();
CLRBIT(ILSW[4], ILSW_4_T2741_TERMINAL);
calc_ints();
CLRBIT(ILSW[4], ILSW_4_T2741_TERMINAL);
calc_ints();
return SCPE_OK;
return SCPE_OK;
}
static struct tag_t2741_map {
int code;
int lcase, ucase;
t_bool shifts;
int code;
int lcase, ucase;
t_bool shifts;
} t2741_map[] = {
{0x4F00, 'A', 'a', TRUE},
{0x3700, 'B', 'b', TRUE},
{0x2F00, 'C', 'c', TRUE},
{0x2A00, 'D', 'd', TRUE},
{0x2900, 'E', 'e', TRUE},
{0x6700, 'F', '_', TRUE},
{0x6200, 'G', 'g', TRUE},
{0x3200, 'H', 'h', TRUE},
{0x4C00, 'I', 'i', TRUE},
{0x6100, 'J', 'j', TRUE},
{0x2C00, 'K', '\'', TRUE},
{0x3100, 'L', 'l', TRUE},
{0x4300, 'M', '|', TRUE},
{0x2500, 'N', 'n', TRUE},
{0x5100, 'O', 'o', TRUE},
{0x6800, 'P', '*', TRUE},
{0x6D00, 'Q', '?', TRUE},
{0x4A00, 'R', 'r', TRUE},
{0x5200, 'S', 's', TRUE},
{0x2000, 'T', '~', TRUE},
{0x2600, 'U', 'u', TRUE},
{0x4600, 'V', 'v', TRUE},
{0x5700, 'W', 'w', TRUE},
{0x2300, 'X', 'x', TRUE},
{0x7300, 'Y', 'y', TRUE},
{0x1500, 'Z', 'z', TRUE},
{0x1300, '0', '&', TRUE},
{0x0200, '1', '?', TRUE},
{0x0400, '2', '?', TRUE},
{0x0700, '3', '<', TRUE},
{0x1000, '4', '?', TRUE},
{0x0800, '5', '=', TRUE},
{0x0D00, '6', '?', TRUE},
{0x0B00, '7', '>', TRUE},
{0x0E00, '8', '?', TRUE},
{0x1600, '9', '|', TRUE},
{0x7000, '/', '\\', TRUE},
{0x7600, '+', '-', TRUE},
{0x6400, '?', '?', TRUE},
{0x4000, '<', '>', TRUE},
{0x6B00, '[', '(', TRUE},
{0x4900, ']', ')', TRUE},
{0x6E00, ',', ';', TRUE},
{0x4500, '.', ':', TRUE},
{0x0100, ' ', 0, FALSE},
{0x5B00, '\r', 0, FALSE},
{0x3B00, '\n', 0, FALSE},
{0x5D00, '\b', 0, FALSE},
{0x5E00, '\t', 0, FALSE},
{0x0001, '\027', 0, FALSE},
{0x4F00, 'A', 'a', TRUE},
{0x3700, 'B', 'b', TRUE},
{0x2F00, 'C', 'c', TRUE},
{0x2A00, 'D', 'd', TRUE},
{0x2900, 'E', 'e', TRUE},
{0x6700, 'F', '_', TRUE},
{0x6200, 'G', 'g', TRUE},
{0x3200, 'H', 'h', TRUE},
{0x4C00, 'I', 'i', TRUE},
{0x6100, 'J', 'j', TRUE},
{0x2C00, 'K', '\'', TRUE},
{0x3100, 'L', 'l', TRUE},
{0x4300, 'M', '|', TRUE},
{0x2500, 'N', 'n', TRUE},
{0x5100, 'O', 'o', TRUE},
{0x6800, 'P', '*', TRUE},
{0x6D00, 'Q', '?', TRUE},
{0x4A00, 'R', 'r', TRUE},
{0x5200, 'S', 's', TRUE},
{0x2000, 'T', '~', TRUE},
{0x2600, 'U', 'u', TRUE},
{0x4600, 'V', 'v', TRUE},
{0x5700, 'W', 'w', TRUE},
{0x2300, 'X', 'x', TRUE},
{0x7300, 'Y', 'y', TRUE},
{0x1500, 'Z', 'z', TRUE},
{0x1300, '0', '&', TRUE},
{0x0200, '1', '?', TRUE},
{0x0400, '2', '?', TRUE},
{0x0700, '3', '<', TRUE},
{0x1000, '4', '?', TRUE},
{0x0800, '5', '=', TRUE},
{0x0D00, '6', '?', TRUE},
{0x0B00, '7', '>', TRUE},
{0x0E00, '8', '?', TRUE},
{0x1600, '9', '|', TRUE},
{0x7000, '/', '\\', TRUE},
{0x7600, '+', '-', TRUE},
{0x6400, '?', '?', TRUE},
{0x4000, '<', '>', TRUE},
{0x6B00, '[', '(', TRUE},
{0x4900, ']', ')', TRUE},
{0x6E00, ',', ';', TRUE},
{0x4500, '.', ':', TRUE},
{0x0100, ' ', 0, FALSE},
{0x5B00, '\r', 0, FALSE},
{0x3B00, '\n', 0, FALSE},
{0x5D00, '\b', 0, FALSE},
{0x5E00, '\t', 0, FALSE},
{0x0001, '\027', 0, FALSE},
};
static uint16 ascii_to_t2741 (int ascii)
{
int i;
uint16 rval = 0;
int i;
uint16 rval = 0;
ascii &= 0xFF;
ascii &= 0xFF;
if (ascii == '\n') /* turn newlines into returns + CIRCLED? */
return CODE_RETURN | (CODE_CIRCLEC >> 8);
if (ascii == '\n') /* turn newlines into returns + CIRCLED? */
return CODE_RETURN | (CODE_CIRCLEC >> 8);
for (i = sizeof(t2741_map)/sizeof(t2741_map[0]); --i >= 0; ) {
if (t2741_map[i].shifts) {
if (t2741_map[i].lcase == ascii) {
rval = t2741_map[i].code;
if (t2741_unit->flags & UNIT_UPCASE) {
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
rval = CODE_SHIFTDOWN | (rval >> 8);
}
return rval;
}
if (t2741_map[i].ucase == ascii) {
rval = t2741_map[i].code;
if (! (t2741_unit->flags & UNIT_UPCASE)) {
SETBIT(t2741_unit->flags, UNIT_UPCASE);
rval = CODE_SHIFTUP | (rval >> 8);
}
return rval;
}
}
else if (t2741_map[i].lcase == ascii)
return t2741_map[i].code;
}
for (i = sizeof(t2741_map)/sizeof(t2741_map[0]); --i >= 0; ) {
if (t2741_map[i].shifts) {
if (t2741_map[i].lcase == ascii) {
rval = t2741_map[i].code;
if (t2741_unit->flags & UNIT_UPCASE) {
CLRBIT(t2741_unit->flags, UNIT_UPCASE);
rval = CODE_SHIFTDOWN | (rval >> 8);
}
return rval;
}
if (t2741_map[i].ucase == ascii) {
rval = t2741_map[i].code;
if (! (t2741_unit->flags & UNIT_UPCASE)) {
SETBIT(t2741_unit->flags, UNIT_UPCASE);
rval = CODE_SHIFTUP | (rval >> 8);
}
return rval;
}
}
else if (t2741_map[i].lcase == ascii)
return t2741_map[i].code;
}
return CODE_UNKNOWN;
return CODE_UNKNOWN;
}
static const char * t2741_to_ascii (uint16 code)
{
int i;
static char string[2] = {'?', '\0'};
int i;
static char string[2] = {'?', '\0'};
switch (code) {
case CODE_SHIFTUP: return "SHIFTUP";
case CODE_SHIFTDOWN: return "SHIFTDN";
case CODE_CIRCLEC: return "CIRCLEC";
case CODE_CIRCLED: return "CIRCLED";
}
switch (code) {
case CODE_SHIFTUP: return "SHIFTUP";
case CODE_SHIFTDOWN: return "SHIFTDN";
case CODE_CIRCLEC: return "CIRCLEC";
case CODE_CIRCLED: return "CIRCLED";
}
for (i = sizeof(t2741_map)/sizeof(t2741_map[0]); --i >= 0; ) {
if (t2741_map[i].code == code) {
if (t2741_map[i].shifts) {
string[0] = (t2741_unit->flags & UNIT_UPCASE) ? t2741_map[i].ucase : t2741_map[i].lcase;
return string;
}
switch (t2741_map[i].lcase) {
case ' ': return " ";
case '\r': return "RETURN";
case '\n': return "LINEFEED";
case '\b': return "BS";
case '\t': return "IDLE";
}
break;
}
}
for (i = sizeof(t2741_map)/sizeof(t2741_map[0]); --i >= 0; ) {
if (t2741_map[i].code == code) {
if (t2741_map[i].shifts) {
string[0] = (t2741_unit->flags & UNIT_UPCASE) ? t2741_map[i].ucase : t2741_map[i].lcase;
return string;
}
switch (t2741_map[i].lcase) {
case ' ': return " ";
case '\r': return "RETURN";
case '\n': return "LINEFEED";
case '\b': return "BS";
case '\t': return "IDLE";
}
break;
}
}
return "?";
return "?";
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -12,23 +12,23 @@
// checkdisk - validates and optionally dumps an IBM1130 DMS2 disk image file
//
// Usage:
// checkdisk [-f] [-d cyl.sec|abssec] [-n count] filename
// checkdisk [-f] [-d cyl.sec|abssec] [-n count] filename
//
// Examples:
// checkdisk file.dsk
// report any misnumbered sectors in file.dsk
// checkdisk file.dsk
// report any misnumbered sectors in file.dsk
//
// checkdisk -f file.dsk
// report and fix any misnumbered sectors
// checkdisk -f file.dsk
// report and fix any misnumbered sectors
//
// checkdisk -d 198.0 file.dsk
// dump cylinder 198 sector 0
// checkdisk -d 198.0 file.dsk
// dump cylinder 198 sector 0
//
// checkdisk -d 0 file.dsk
// dump absolute 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
// checkdisk -d 198.0 -n 4 file.dsk
// dump 4 sectors starting at m.n
// -----------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
@ -38,7 +38,7 @@
#ifdef _WIN32
# include <io.h>
#else
long filelength (int fno);
long filelength (int fno);
# include <sys/types.h>
# include <sys/stat.h>
#endif
@ -49,11 +49,11 @@
# 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_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";
@ -64,171 +64,171 @@ 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];
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;
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;
case 'd':
dump = TRUE;
if (i >= argc)
bail(usestr);
if (i >= argc)
bail(usestr);
argval = argv[i++];
if (strchr(argval, '.') != NULL) {
if (sscanf(argval, "%d.%d", &cyl, &sec) != 2)
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);
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");
if (dsec < 0 || dsec >= (DSK_NUMCY*DSK_NUMSF*DSK_NUMSC))
bail("No such sector");
break;
break;
case 'n':
if (i >= argc)
bail(usestr);
case 'n':
if (i >= argc)
bail(usestr);
argval = argv[i++];
if (sscanf(argval, "%d", &nsec) != 1)
bail(usestr);
argval = argv[i++];
if (sscanf(argval, "%d", &nsec) != 1)
bail(usestr);
if (nsec <= 0)
bail(usestr);
if (nsec <= 0)
bail(usestr);
break;
break;
default:
bail(usestr);
}
}
}
else if (fname == NULL)
fname = arg;
else
bail(usestr);
}
default:
bail(usestr);
}
}
}
else if (fname == NULL)
fname = arg;
else
bail(usestr);
}
if (fname == NULL)
bail(usestr);
if (fname == NULL)
bail(usestr);
if ((fp = fopen(fname, "rb+")) == NULL) {
perror(fname);
return 1;
}
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);
}
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;
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;
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 (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 (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 (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 (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 (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 (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 (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;
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);
}
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);
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);
}
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(' ');
}
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++;
}
dsec++;
}
return 0;
return 0;
}
void bail (char *msg)
{
fprintf(stderr, "%s\n", msg);
exit(1);
fprintf(stderr, "%s\n", msg);
exit(1);
}
/* ------------------------------------------------------------------------
@ -237,14 +237,14 @@ void bail (char *msg)
char *lowcase (char *str)
{
char *s;
char *s;
for (s = str; *s; s++) {
if (*s >= 'A' && *s <= 'Z')
*s += 32;
}
for (s = str; *s; s++) {
if (*s >= 'A' && *s <= 'Z')
*s += 32;
}
return str;
return str;
}
#ifndef _WIN32
@ -254,9 +254,9 @@ long filelength (int fno)
struct stat sb;
if (fstat(fno, &sb) != 0)
return 0;
return 0;
return (long) sb.st_size;
return (long) sb.st_size;
}
#endif

View file

@ -13,7 +13,7 @@
// needs LET/SLET listing routine.
//
// usage:
// diskview -v diskfile
// diskview -v diskfile
#include <stdio.h>
#include <stdlib.h>
@ -31,13 +31,13 @@
# define BOOL int
#endif
#define NOT_DEF 0x0658 // defective cylinder table entry means no defect
#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 */
#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;
@ -47,10 +47,10 @@ WORD dcom[DSK_NUMWD];
#pragma pack(2)
struct tag_slet {
WORD phid;
WORD addr;
WORD nwords;
WORD sector;
WORD phid;
WORD addr;
WORD nwords;
WORD sector;
} slet[SLETLEN];
#pragma pack()
@ -77,188 +77,188 @@ char *trim (char *s);
int main (int argc, char **argv)
{
char *fname = NULL, *arg;
static char usestr[] = "Usage: diskview [-v] filename";
int i;
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;
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);
}
default:
bail(usestr);
}
}
}
else if (fname == NULL)
fname = arg;
else
bail(usestr);
}
if (fname == NULL)
bail(usestr);
if (fname == NULL)
bail(usestr);
if ((fp = fopen(fname, "rb")) == NULL) {
perror(fname);
return 2;
}
if ((fp = fopen(fname, "rb")) == NULL) {
perror(fname);
return 2;
}
printf("%s:\n", fname);
printf("%s:\n", fname);
checksectors();
getdcyl();
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();
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;
fclose(fp);
return 0;
}
// checksectors - verify that all sectors are properly numbered
void checksectors ()
{
WORD sec = 0;
WORD sec = 0;
fseek(fp, 0, SEEK_SET);
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");
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);
}
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");
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;
int i, cyl, ssec;
sec &= 0x7FF; // mask of drive bits, if any
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");
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");
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;
int i, nline = 0;
for (i = 0; i < nwords; i++) {
if (nline == 16) {
putchar('\n');
nline = 0;
}
for (i = 0; i < nwords; i++) {
if (nline == 16) {
putchar('\n');
nline = 0;
}
printf("%04x", buf[i]);
nline++;
}
putchar('\n');
printf("%04x", buf[i]);
nline++;
}
putchar('\n');
}
void showmajor (char *label)
{
int i;
int i;
printf("\n--- %s ", label);
printf("\n--- %s ", label);
for (i = strlen(label); i < 40; i++)
putchar('-');
for (i = strlen(label); i < 40; i++)
putchar('-');
putchar('\n');
putchar('\n');
putchar('\n');
putchar('\n');
}
void name (char *label)
{
printf("%-32.32s ", label);
printf("%-32.32s ", label);
}
void pbf (char *label, WORD *buf, int nwords)
{
int i, nout;
int i, nout;
name(label);
name(label);
for (i = nout = 0; i < nwords; i++, nout++) {
if (nout == 8) {
putchar('\n');
name("");
nout = 0;
}
printf(" %04x", buf[i]);
}
for (i = nout = 0; i < nwords; i++, nout++) {
if (nout == 8) {
putchar('\n');
name("");
nout = 0;
}
printf(" %04x", buf[i]);
}
putchar('\n');
putchar('\n');
}
void prt (char *label, char *fmt, ...)
{
va_list args;
va_list args;
name(label);
name(label);
putchar(' ');
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
putchar(' ');
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
putchar('\n');
putchar('\n');
}
void dump_id (void)
{
showmajor("Sector 0 - ID & coldstart");
getsector(0, buf);
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);
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
@ -304,257 +304,257 @@ void dump_id (void)
#define CSHN 90 // NO. SCTRS IN CUSHION AREA
struct tag_dcominfo {
char *nm;
int offset;
char *descr;
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
"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];
struct tag_dcominfo *d;
char txt[50];
showmajor("Sector 1 - DCOM");
getsector(1, dcom);
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);
}
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);
showmajor("Sector 2 - Resident Image");
getsector(2, buf);
dump(verbose ? SECLEN : 32);
}
struct {
int pfrom, pto;
int printed;
char *name;
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
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;
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));
}
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;
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;
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 = " ";
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;
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);
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);
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 (iphase < 0)
iphase = -iphase;
if (sletinfo[j].pfrom == 0)
printf(" ???");
else if (! sletinfo[j].printed) {
printf(" %s", sletinfo[j].name);
sletinfo[j].printed = TRUE;
}
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;
}
}
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
max_sec = MAX(max_sec, sec+nsecs-1); // find last sector used
putchar('\n');
putchar('\n');
if (i >= 15 && ! verbose) {
printf("...\n");
break;
}
}
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,
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,
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;
int j;
for (j = 32; j < 128; j++)
if (ascii_to_ebcdic_table[j] == ch)
return j;
for (j = 32; j < 128; j++)
if (ascii_to_ebcdic_table[j] == ch)
return j;
return '?';
return '?';
}
#define HDR_LEN 120
void dump_hdng(void)
{
int i;
char str[HDR_LEN+1], *p = str;
int i;
char str[HDR_LEN+1], *p = str;
showmajor("Sector 7 - Heading");
getsector(7, buf);
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);
}
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);
*p = '\0';
trim(str);
printf("%s\n", str);
}
BOOL mget (int offset, char *name)
{
char title[80];
char title[80];
if (dcom[offset] == 0)
return FALSE;
if (dcom[offset] == 0)
return FALSE;
getsector(dcom[offset], buf);
sprintf(title, "Sector %x - %s", dcom[offset], name);
showmajor(title);
return TRUE;
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;
if (! mget(SCRA, "SCRA"))
return;
dump(verbose ? SECLEN : 32);
dump(verbose ? SECLEN : 32);
}
void dump_let (void)
{
if (! mget(ULET, "LET"))
return;
if (! mget(ULET, "LET"))
return;
}
void dump_flet (void)
{
if (! mget(FLET, "FLET"))
return;
if (! mget(FLET, "FLET"))
return;
}
void dump_cib (void)
{
if (! mget(CIBA, "CIB"))
return;
if (! mget(CIBA, "CIB"))
return;
dump(verbose ? SECLEN : 32);
dump(verbose ? SECLEN : 32);
}
#define LFHD 5 // WORD COUNT OF LET/FLET HEADER PMN09970
@ -568,14 +568,14 @@ void dump_cib (void)
void bail (char *fmt, ...)
{
va_list args;
va_list args;
va_start(args, fmt);
fprintf(stderr, fmt, args);
va_end(args);
putchar('\n');
va_start(args, fmt);
fprintf(stderr, fmt, args);
va_end(args);
putchar('\n');
exit(1);
exit(1);
}
// ---------------------------------------------------------------------------------
@ -584,14 +584,14 @@ void bail (char *fmt, ...)
char *trim (char *s)
{
char *os = s, *nb;
char *os = s, *nb;
for (nb = s-1; *s; s++)
if (*s > ' ')
nb = s;
for (nb = s-1; *s; s++)
if (*s > ' ')
nb = s;
nb[1] = '\0';
return os;
nb[1] = '\0';
return os;
}
/* ------------------------------------------------------------------------
@ -600,13 +600,13 @@ char *trim (char *s)
char *lowcase (char *str)
{
char *s;
char *s;
for (s = str; *s; s++) {
if (*s >= 'A' && *s <= 'Z')
*s += 32;
}
for (s = str; *s; s++) {
if (*s >= 'A' && *s <= 'Z')
*s += 32;
}
return str;
return str;
}

File diff suppressed because it is too large Load diff

View file

@ -26,218 +26,218 @@ 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";
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];
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 (*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 (fname == NULL) // there must be a name
bail(usestr);
if ((fd = fopen(fname, "rb")) == NULL) {
perror(fname);
return 1;
}
if ((fd = fopen(fname, "rb")) == NULL) {
perror(fname);
return 1;
}
while (fxread(buf, sizeof(short), 80, fd) == 80) {
if (coldstart) {
format_coldstart(buf);
break;
}
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);
}
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");
}
if (coldstart) {
if (fxread(buf, sizeof(short), 1, fd) == 1)
bail("Coldstart deck has more than one card");
}
fclose(fd);
fclose(fd);
return 0;
return 0;
}
void format_coldstart (unsigned short *buf)
{
int i, nout = 0;
unsigned short word;
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);
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);
if (nout >= 8) {
fputs(",\n", stdout);
nout = 0;
}
else if (i > 0)
fputs(", ", stdout);
printf("0x%04x", word);
nout++;
}
printf("0x%04x", word);
nout++;
}
putchar('\n');
putchar('\n');
}
typedef struct {
unsigned short hollerith;
char ascii;
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
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;
int i;
h &= 0xFFF0;
h &= 0xFFF0;
for (i = 0; i < sizeof(cardcode_029) / sizeof(CPCODE); i++)
if (cardcode_029[i].hollerith == h)
return cardcode_029[i].ascii;
for (i = 0; i < sizeof(cardcode_029) / sizeof(CPCODE); i++)
if (cardcode_029[i].hollerith == h)
return cardcode_029[i].ascii;
return '?';
return '?';
}
void bail (char *msg)
{
fprintf(stderr, "%s\n", msg);
exit(1);
fprintf(stderr, "%s\n", msg);
exit(1);
}