mirror of
https://github.com/simh/simh.git
synced 2026-04-19 09:19:40 +00:00
Added CR-LF line endings. Tabs replaced with spaces
Text files stored with CR-LF line endings, all tabs replaced with 4 spaces.
This commit is contained in:
198
SSEM/ssem_sys.c
198
SSEM/ssem_sys.c
@@ -74,10 +74,10 @@ const char *sim_stop_messages[] = {
|
||||
t_stat ssem_dump (FILE *fi)
|
||||
{
|
||||
if (sim_fwrite(A, sizeof(int32), 1, fi) != 1 ||
|
||||
sim_fwrite(C, sizeof(uint32), 1, fi) != 1 ||
|
||||
sim_fwrite(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) {
|
||||
return SCPE_IOERR;
|
||||
}
|
||||
sim_fwrite(C, sizeof(uint32), 1, fi) != 1 ||
|
||||
sim_fwrite(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) {
|
||||
return SCPE_IOERR;
|
||||
}
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ t_stat ssem_load_dmp (FILE *fi)
|
||||
{
|
||||
C[1] = 0;
|
||||
if (sim_fread(A, sizeof(int32), 1, fi) != 1 ||
|
||||
sim_fread(C, sizeof(uint32), 1, fi) != 1 ||
|
||||
sim_fread(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) {
|
||||
return SCPE_IOERR;
|
||||
}
|
||||
sim_fread(C, sizeof(uint32), 1, fi) != 1 ||
|
||||
sim_fread(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) {
|
||||
return SCPE_IOERR;
|
||||
}
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
@@ -121,9 +121,9 @@ return ssem_load_dmp(fi);
|
||||
t_stat ssem_fprint_decimal (FILE *of, uint32 inst)
|
||||
{
|
||||
if (inst & SMASK)
|
||||
fprintf (of, "%d [%u]", inst, inst);
|
||||
fprintf (of, "%d [%u]", inst, inst);
|
||||
else
|
||||
fprintf (of, "%d", inst);
|
||||
fprintf (of, "%d", inst);
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
@@ -136,9 +136,9 @@ uint32 n;
|
||||
|
||||
n = inst;
|
||||
for (i = 0; i < nbits; i++) {
|
||||
fprintf(of, "%d", n & 1 ? 1 : 0);
|
||||
n >>= 1;
|
||||
}
|
||||
fprintf(of, "%d", n & 1 ? 1 : 0);
|
||||
n >>= 1;
|
||||
}
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
@@ -152,10 +152,10 @@ if (!flag) return ssem_fprint_binary_number(of, inst, 32);
|
||||
|
||||
op = I_GETOP (inst);
|
||||
if (op != OP_TEST && op != OP_STOP) {
|
||||
ea = I_GETEA (inst);
|
||||
ssem_fprint_binary_number(of, ea, 5);
|
||||
fprintf (of, " ");
|
||||
}
|
||||
ea = I_GETEA (inst);
|
||||
ssem_fprint_binary_number(of, ea, 5);
|
||||
fprintf (of, " ");
|
||||
}
|
||||
ssem_fprint_binary_number(of, op, 3);
|
||||
|
||||
return SCPE_OK;
|
||||
@@ -167,7 +167,7 @@ return SCPE_OK;
|
||||
competition reference manual:
|
||||
"The Manchester University Small Scale Experimental Machine
|
||||
Programmer's Reference manual"
|
||||
http://www.computer50.org/mark1/prog98/ssemref.html
|
||||
http://www.computer50.org/mark1/prog98/ssemref.html
|
||||
*/
|
||||
|
||||
t_stat ssem_fprint_competition_mnemonic (FILE *of, uint32 inst)
|
||||
@@ -176,42 +176,42 @@ uint32 op, ea;
|
||||
|
||||
op = I_GETOP (inst);
|
||||
switch (op) {
|
||||
case OP_JUMP_INDIRECT: /* JMP */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "JMP %d", ea);
|
||||
case OP_JUMP_INDIRECT: /* JMP */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "JMP %d", ea);
|
||||
break;
|
||||
|
||||
case OP_JUMP_INDIRECT_RELATIVE: /* JRP */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "JRP %d", ea);
|
||||
case OP_JUMP_INDIRECT_RELATIVE: /* JRP */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "JRP %d", ea);
|
||||
break;
|
||||
|
||||
case OP_LOAD_NEGATED: /* LDN */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "LDN %d", ea);
|
||||
case OP_LOAD_NEGATED: /* LDN */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "LDN %d", ea);
|
||||
break;
|
||||
|
||||
case OP_STORE: /* STO */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "STO %d", ea);
|
||||
case OP_STORE: /* STO */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "STO %d", ea);
|
||||
break;
|
||||
|
||||
case OP_SUBSTRACT: /* SUB */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "SUB %d", ea);
|
||||
case OP_SUBSTRACT: /* SUB */
|
||||
ea = I_GETEA (inst);
|
||||
fprintf (of, "SUB %d", ea);
|
||||
break;
|
||||
|
||||
case OP_UNDOCUMENTED: /* invalid instruction */
|
||||
return SCPE_ARG;
|
||||
case OP_UNDOCUMENTED: /* invalid instruction */
|
||||
return SCPE_ARG;
|
||||
|
||||
case OP_TEST: /* CMP */
|
||||
fprintf (of, "CMP");
|
||||
case OP_TEST: /* CMP */
|
||||
fprintf (of, "CMP");
|
||||
break;
|
||||
|
||||
case OP_STOP: /* STOP */
|
||||
fprintf (of, "STOP");
|
||||
break; /* end switch */
|
||||
}
|
||||
case OP_STOP: /* STOP */
|
||||
fprintf (of, "STOP");
|
||||
break; /* end switch */
|
||||
}
|
||||
|
||||
return SCPE_OK;
|
||||
}
|
||||
@@ -233,25 +233,25 @@ t_stat fprint_sym (FILE *of, t_addr addr, t_value *val,
|
||||
{
|
||||
uint32 inst;
|
||||
|
||||
if (sw & SWMASK ('H')) return SCPE_ARG; /* hexadecimal? */
|
||||
if (sw & SWMASK ('H')) return SCPE_ARG; /* hexadecimal? */
|
||||
|
||||
inst = val[0];
|
||||
|
||||
if (sw & SWMASK ('D')) /* decimal? */
|
||||
return ssem_fprint_decimal(of, inst);
|
||||
if (sw & SWMASK ('D')) /* decimal? */
|
||||
return ssem_fprint_decimal(of, inst);
|
||||
|
||||
if (sw & SWMASK ('M')) { /* mnemomic? */
|
||||
return ssem_fprint_competition_mnemonic(of, inst);
|
||||
}
|
||||
if (sw & SWMASK ('M')) { /* mnemomic? */
|
||||
return ssem_fprint_competition_mnemonic(of, inst);
|
||||
}
|
||||
|
||||
return ssem_fprint_binary(of, inst, sw & SWMASK ('I') || sw & SWMASK ('M'));
|
||||
}
|
||||
|
||||
static const char *opcode[] = {
|
||||
"JMP", "JRP", "LDN",
|
||||
"STO", "SUB", "",
|
||||
"CMP", "STOP",
|
||||
NULL
|
||||
"JMP", "JRP", "LDN",
|
||||
"STO", "SUB", "",
|
||||
"CMP", "STOP",
|
||||
NULL
|
||||
};
|
||||
|
||||
/* Utility function - parses decimal number. */
|
||||
@@ -262,16 +262,16 @@ char *start;
|
||||
int n;
|
||||
|
||||
start = cptr;
|
||||
if (*cptr == '-') cptr++; /* skip sign */
|
||||
if (*cptr == '-') cptr++; /* skip sign */
|
||||
n = 0;
|
||||
while (*cptr >= '0' && *cptr <= '9') {
|
||||
n = (n * 10) + (*cptr - '0');
|
||||
cptr++;
|
||||
}
|
||||
n = (n * 10) + (*cptr - '0');
|
||||
cptr++;
|
||||
}
|
||||
if (*start == '-') n = -n;
|
||||
if (*start) *start = 'x';
|
||||
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
|
||||
*val = n;
|
||||
return SCPE_OK;
|
||||
@@ -285,7 +285,7 @@ return SCPE_OK;
|
||||
manual:
|
||||
"The Manchester University Small Scale Experimental Machine
|
||||
Programmer's Reference manual"
|
||||
http://www.computer50.org/mark1/prog98/ssemref.html
|
||||
http://www.computer50.org/mark1/prog98/ssemref.html
|
||||
*/
|
||||
|
||||
t_stat parse_sym_m (char *cptr, t_value *val)
|
||||
@@ -299,25 +299,25 @@ cptr = get_glyph(cptr, gbuf, 0);
|
||||
if (*start) *start = 'x';
|
||||
|
||||
for (n = 0; opcode[n] != NULL && strcmp(opcode[n], gbuf) != 0; n++) ;
|
||||
if (opcode[n] == NULL) return SCPE_ARG; /* invalid mnemonic? */
|
||||
if (opcode[n] == NULL) return SCPE_ARG; /* invalid mnemonic? */
|
||||
|
||||
if (!(*cptr) && n > OP_UNDOCUMENTED && n <= OP_STOP) {
|
||||
*val = n << I_V_OP; return SCPE_OK;
|
||||
}
|
||||
*val = n << I_V_OP; return SCPE_OK;
|
||||
}
|
||||
|
||||
while (isspace (*cptr)) cptr++; /* absorb spaces */
|
||||
while (isspace (*cptr)) cptr++; /* absorb spaces */
|
||||
|
||||
if (*cptr < '0' || *cptr > '9') return SCPE_ARG; /* address expected */
|
||||
if (*cptr < '0' || *cptr > '9') return SCPE_ARG; /* address expected */
|
||||
|
||||
a = 0;
|
||||
while (*cptr >= '0' && *cptr <= '9') {
|
||||
a = (a * 10) + (*cptr - '0');
|
||||
cptr++;
|
||||
}
|
||||
a = (a * 10) + (*cptr - '0');
|
||||
cptr++;
|
||||
}
|
||||
|
||||
if (a >= MEMSIZE) return SCPE_ARG; /* invalid address? */
|
||||
if (a >= MEMSIZE) return SCPE_ARG; /* invalid address? */
|
||||
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
|
||||
*val = (n << I_V_OP) + a;
|
||||
return SCPE_OK;
|
||||
@@ -335,13 +335,13 @@ start = cptr;
|
||||
count = 0;
|
||||
n = 0;
|
||||
while (*cptr == '0' || *cptr == '1') {
|
||||
n = n + ((*cptr - '0') << count);
|
||||
count++;
|
||||
cptr++;
|
||||
}
|
||||
n = n + ((*cptr - '0') << count);
|
||||
count++;
|
||||
cptr++;
|
||||
}
|
||||
if (*start) *start = 'x';
|
||||
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
|
||||
*val = n;
|
||||
return SCPE_OK;
|
||||
@@ -359,33 +359,33 @@ start = cptr;
|
||||
count = 0;
|
||||
n = 0;
|
||||
while (*cptr == '0' || *cptr == '1') {
|
||||
n = n + ((*cptr - '0') << count);
|
||||
count++;
|
||||
cptr++;
|
||||
}
|
||||
n = n + ((*cptr - '0') << count);
|
||||
count++;
|
||||
cptr++;
|
||||
}
|
||||
if (*start) *start = 'x';
|
||||
|
||||
if (!(*cptr) && n > OP_UNDOCUMENTED && n <= OP_STOP) {
|
||||
*val = n << I_V_OP; return SCPE_OK;
|
||||
}
|
||||
*val = n << I_V_OP; return SCPE_OK;
|
||||
}
|
||||
|
||||
a = n;
|
||||
if (a >= MEMSIZE) return SCPE_ARG; /* invalid addresss */
|
||||
if (a >= MEMSIZE) return SCPE_ARG; /* invalid addresss */
|
||||
|
||||
while (isspace (*cptr)) cptr++; /* absorb spaces */
|
||||
while (isspace (*cptr)) cptr++; /* absorb spaces */
|
||||
|
||||
if (*cptr != '0' && *cptr != '1') return SCPE_ARG; /* instruction expected */
|
||||
if (*cptr != '0' && *cptr != '1') return SCPE_ARG; /* instruction expected */
|
||||
|
||||
count = 0;
|
||||
n = 0;
|
||||
while (*cptr == '0' || *cptr == '1') {
|
||||
n = n + ((*cptr - '0') << count);
|
||||
count++;
|
||||
cptr++;
|
||||
}
|
||||
if (n >= OP_UNDOCUMENTED) return SCPE_ARG; /* invalid instruction? */
|
||||
n = n + ((*cptr - '0') << count);
|
||||
count++;
|
||||
cptr++;
|
||||
}
|
||||
if (n >= OP_UNDOCUMENTED) return SCPE_ARG; /* invalid instruction? */
|
||||
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
if (*cptr) return SCPE_ARG; /* junk at end? */
|
||||
|
||||
*val = (n << I_V_OP) + a;
|
||||
return SCPE_OK;
|
||||
@@ -406,21 +406,21 @@ return SCPE_OK;
|
||||
t_stat parse_sym (char *cptr, t_addr addr, UNIT *uptr, t_value *val, int32 sw)
|
||||
{
|
||||
|
||||
if (sw & SWMASK ('H')) return SCPE_ARG; /* hexadecimal? */
|
||||
if (sw & SWMASK ('H')) return SCPE_ARG; /* hexadecimal? */
|
||||
|
||||
while (isspace (*cptr)) cptr++; /* absorb spaces */
|
||||
while (isspace (*cptr)) cptr++; /* absorb spaces */
|
||||
|
||||
if (sw & SWMASK ('D')) { /* decimal? */
|
||||
return parse_sym_d (cptr, val);
|
||||
}
|
||||
if (sw & SWMASK ('D')) { /* decimal? */
|
||||
return parse_sym_d (cptr, val);
|
||||
}
|
||||
|
||||
if (sw & SWMASK ('I')) { /* backward binary instruction? */
|
||||
return parse_sym_i (cptr, val);
|
||||
}
|
||||
if (sw & SWMASK ('I')) { /* backward binary instruction? */
|
||||
return parse_sym_i (cptr, val);
|
||||
}
|
||||
|
||||
if (sw & SWMASK ('M')) { /* mnemonic? */
|
||||
return parse_sym_m (cptr, val);
|
||||
}
|
||||
if (sw & SWMASK ('M')) { /* mnemonic? */
|
||||
return parse_sym_m (cptr, val);
|
||||
}
|
||||
|
||||
return parse_sym_b(cptr, val); /* backward binary number */
|
||||
return parse_sym_b(cptr, val); /* backward binary number */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user