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:
parent
f118a724fe
commit
865ae4d091
2 changed files with 141 additions and 141 deletions
|
@ -48,13 +48,13 @@
|
|||
|
||||
<13:15> operation
|
||||
|
||||
000 0 C[0] <- S[n]
|
||||
001 1 C[0] <- C[0] + S[n]
|
||||
010 2 A[0] <- -S[n]
|
||||
011 3 S[n] <- A[0]
|
||||
100 4 A[0] <- A[0] - S[n]
|
||||
110 6 C[0] <- C[0] + 1 if (A[0] < 0)
|
||||
111 7 Stop the machine
|
||||
000 0 C[0] <- S[n]
|
||||
001 1 C[0] <- C[0] + S[n]
|
||||
010 2 A[0] <- -S[n]
|
||||
011 3 S[n] <- A[0]
|
||||
100 4 A[0] <- A[0] - S[n]
|
||||
110 6 C[0] <- C[0] + 1 if (A[0] < 0)
|
||||
111 7 Stop the machine
|
||||
|
||||
The SSEM has 32 32b words of memory.
|
||||
|
||||
|
@ -80,10 +80,10 @@
|
|||
|
||||
#include "ssem_defs.h"
|
||||
|
||||
uint32 S[MEMSIZE] = { 0 }; /* storage (memory) */
|
||||
uint32 S[MEMSIZE] = { 0 }; /* storage (memory) */
|
||||
|
||||
int32 A[MEMSIZE] = { 0 }; /* A[0] accumulator */
|
||||
uint32 C[MEMSIZE] = { 0, 0 }; /* C[0] current instruction */
|
||||
int32 A[MEMSIZE] = { 0 }; /* A[0] accumulator */
|
||||
uint32 C[MEMSIZE] = { 0, 0 }; /* C[0] current instruction */
|
||||
/* C[1] present instruction */
|
||||
uint32 Staticisor = 0;
|
||||
|
||||
|
@ -115,7 +115,7 @@ REG cpu_reg[] = {
|
|||
};
|
||||
|
||||
MTAB cpu_mod[] = {
|
||||
{ UNIT_SSEM, 0, "Manchester SSEM (Small Scale Experimental Machine)", "SSEM" },
|
||||
{ UNIT_SSEM, 0, "Manchester University SSEM (Small Scale Experimental Machine)", "SSEM" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -142,21 +142,21 @@ do {
|
|||
}
|
||||
#endif
|
||||
if (reason = sim_process_event ()) break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sim_brk_summ && /* breakpoint? */
|
||||
sim_brk_test (*C, SWMASK ('E'))) {
|
||||
reason = STOP_IBKPT; /* stop simulation */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Increment current instruction */
|
||||
*C = (*C + 1) & AMASK;
|
||||
/* Increment current instruction */
|
||||
*C = (*C + 1) & AMASK;
|
||||
|
||||
/* Get present instruction */
|
||||
/* Get present instruction */
|
||||
C[1] = Read (*C);
|
||||
|
||||
Staticisor = C[1] & IMASK; /* get instruction */
|
||||
Staticisor = C[1] & IMASK; /* get instruction */
|
||||
sim_interval = sim_interval - 1;
|
||||
|
||||
if (reason = cpu_one_inst (*C, Staticisor)) { /* one instr; error? */
|
||||
|
@ -202,45 +202,45 @@ t_stat cpu_one_inst (uint32 opc, uint32 ir)
|
|||
uint32 ea, op;
|
||||
t_stat reason = 0;
|
||||
|
||||
op = I_GETOP (ir); /* opcode */
|
||||
switch (op) { /* case on opcode */
|
||||
op = I_GETOP (ir); /* opcode */
|
||||
switch (op) { /* case on opcode */
|
||||
|
||||
case OP_JUMP_INDIRECT: /* C[0] <- S[ea] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*C = Read(ea);
|
||||
case OP_JUMP_INDIRECT: /* C[0] <- S[ea] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*C = Read(ea);
|
||||
break;
|
||||
|
||||
case OP_JUMP_INDIRECT_RELATIVE: /* C[0] <- C[0] + S[ea] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*C += Read(ea);
|
||||
case OP_JUMP_INDIRECT_RELATIVE: /* C[0] <- C[0] + S[ea] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*C += Read(ea);
|
||||
break;
|
||||
|
||||
case OP_LOAD_NEGATED: /* A[0] <- -S[ea] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*A = -((int32)Read(ea));
|
||||
case OP_LOAD_NEGATED: /* A[0] <- -S[ea] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*A = -((int32)Read(ea));
|
||||
break;
|
||||
|
||||
case OP_STORE: /* S[ea] <- A[0] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
Write(ea, (uint32) *A);
|
||||
case OP_STORE: /* S[ea] <- A[0] */
|
||||
ea = I_GETEA (ir); /* address */
|
||||
Write(ea, (uint32) *A);
|
||||
break;
|
||||
|
||||
case OP_SUBSTRACT: /* A[0] <- A[0] - S[ea] */
|
||||
case OP_UNDOCUMENTED:
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*A -= ((int32) Read(ea));
|
||||
case OP_SUBSTRACT: /* A[0] <- A[0] - S[ea] */
|
||||
case OP_UNDOCUMENTED:
|
||||
ea = I_GETEA (ir); /* address */
|
||||
*A -= ((int32) Read(ea));
|
||||
break;
|
||||
|
||||
case OP_TEST: /* C[0] <- C[0] + 1 if (A[0] < 0) */
|
||||
if (*A < 0){
|
||||
*C += 1;
|
||||
}
|
||||
case OP_TEST: /* C[0] <- C[0] + 1 if (A[0] < 0) */
|
||||
if (*A < 0){
|
||||
*C += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_STOP: /* Stop the machine */
|
||||
reason = STOP_STOP; /* stop simulation */
|
||||
case OP_STOP: /* Stop the machine */
|
||||
reason = STOP_STOP; /* stop simulation */
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end switch */
|
||||
|
||||
return reason;
|
||||
}
|
||||
|
|
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 */
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue