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:
Gerardo Ospina 2013-05-13 14:31:24 -05:00
parent f118a724fe
commit 865ae4d091
2 changed files with 141 additions and 141 deletions

View file

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

View file

@ -74,10 +74,10 @@ const char *sim_stop_messages[] = {
t_stat ssem_dump (FILE *fi) t_stat ssem_dump (FILE *fi)
{ {
if (sim_fwrite(A, sizeof(int32), 1, fi) != 1 || if (sim_fwrite(A, sizeof(int32), 1, fi) != 1 ||
sim_fwrite(C, sizeof(uint32), 1, fi) != 1 || sim_fwrite(C, sizeof(uint32), 1, fi) != 1 ||
sim_fwrite(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) { sim_fwrite(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) {
return SCPE_IOERR; return SCPE_IOERR;
} }
return SCPE_OK; return SCPE_OK;
} }
@ -87,10 +87,10 @@ t_stat ssem_load_dmp (FILE *fi)
{ {
C[1] = 0; C[1] = 0;
if (sim_fread(A, sizeof(int32), 1, fi) != 1 || if (sim_fread(A, sizeof(int32), 1, fi) != 1 ||
sim_fread(C, sizeof(uint32), 1, fi) != 1 || sim_fread(C, sizeof(uint32), 1, fi) != 1 ||
sim_fread(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) { sim_fread(S, sizeof(uint32), MEMSIZE, fi) != MEMSIZE) {
return SCPE_IOERR; return SCPE_IOERR;
} }
return SCPE_OK; return SCPE_OK;
} }
@ -121,9 +121,9 @@ return ssem_load_dmp(fi);
t_stat ssem_fprint_decimal (FILE *of, uint32 inst) t_stat ssem_fprint_decimal (FILE *of, uint32 inst)
{ {
if (inst & SMASK) if (inst & SMASK)
fprintf (of, "%d [%u]", inst, inst); fprintf (of, "%d [%u]", inst, inst);
else else
fprintf (of, "%d", inst); fprintf (of, "%d", inst);
return SCPE_OK; return SCPE_OK;
} }
@ -136,9 +136,9 @@ uint32 n;
n = inst; n = inst;
for (i = 0; i < nbits; i++) { for (i = 0; i < nbits; i++) {
fprintf(of, "%d", n & 1 ? 1 : 0); fprintf(of, "%d", n & 1 ? 1 : 0);
n >>= 1; n >>= 1;
} }
return SCPE_OK; return SCPE_OK;
} }
@ -152,10 +152,10 @@ if (!flag) return ssem_fprint_binary_number(of, inst, 32);
op = I_GETOP (inst); op = I_GETOP (inst);
if (op != OP_TEST && op != OP_STOP) { if (op != OP_TEST && op != OP_STOP) {
ea = I_GETEA (inst); ea = I_GETEA (inst);
ssem_fprint_binary_number(of, ea, 5); ssem_fprint_binary_number(of, ea, 5);
fprintf (of, " "); fprintf (of, " ");
} }
ssem_fprint_binary_number(of, op, 3); ssem_fprint_binary_number(of, op, 3);
return SCPE_OK; return SCPE_OK;
@ -167,7 +167,7 @@ return SCPE_OK;
competition reference manual: competition reference manual:
"The Manchester University Small Scale Experimental Machine "The Manchester University Small Scale Experimental Machine
Programmer's Reference manual" 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) t_stat ssem_fprint_competition_mnemonic (FILE *of, uint32 inst)
@ -176,42 +176,42 @@ uint32 op, ea;
op = I_GETOP (inst); op = I_GETOP (inst);
switch (op) { switch (op) {
case OP_JUMP_INDIRECT: /* JMP */ case OP_JUMP_INDIRECT: /* JMP */
ea = I_GETEA (inst); ea = I_GETEA (inst);
fprintf (of, "JMP %d", ea); fprintf (of, "JMP %d", ea);
break; break;
case OP_JUMP_INDIRECT_RELATIVE: /* JRP */ case OP_JUMP_INDIRECT_RELATIVE: /* JRP */
ea = I_GETEA (inst); ea = I_GETEA (inst);
fprintf (of, "JRP %d", ea); fprintf (of, "JRP %d", ea);
break; break;
case OP_LOAD_NEGATED: /* LDN */ case OP_LOAD_NEGATED: /* LDN */
ea = I_GETEA (inst); ea = I_GETEA (inst);
fprintf (of, "LDN %d", ea); fprintf (of, "LDN %d", ea);
break; break;
case OP_STORE: /* STO */ case OP_STORE: /* STO */
ea = I_GETEA (inst); ea = I_GETEA (inst);
fprintf (of, "STO %d", ea); fprintf (of, "STO %d", ea);
break; break;
case OP_SUBSTRACT: /* SUB */ case OP_SUBSTRACT: /* SUB */
ea = I_GETEA (inst); ea = I_GETEA (inst);
fprintf (of, "SUB %d", ea); fprintf (of, "SUB %d", ea);
break; break;
case OP_UNDOCUMENTED: /* invalid instruction */ case OP_UNDOCUMENTED: /* invalid instruction */
return SCPE_ARG; return SCPE_ARG;
case OP_TEST: /* CMP */ case OP_TEST: /* CMP */
fprintf (of, "CMP"); fprintf (of, "CMP");
break; break;
case OP_STOP: /* STOP */ case OP_STOP: /* STOP */
fprintf (of, "STOP"); fprintf (of, "STOP");
break; /* end switch */ break; /* end switch */
} }
return SCPE_OK; return SCPE_OK;
} }
@ -233,25 +233,25 @@ t_stat fprint_sym (FILE *of, t_addr addr, t_value *val,
{ {
uint32 inst; uint32 inst;
if (sw & SWMASK ('H')) return SCPE_ARG; /* hexadecimal? */ if (sw & SWMASK ('H')) return SCPE_ARG; /* hexadecimal? */
inst = val[0]; inst = val[0];
if (sw & SWMASK ('D')) /* decimal? */ if (sw & SWMASK ('D')) /* decimal? */
return ssem_fprint_decimal(of, inst); return ssem_fprint_decimal(of, inst);
if (sw & SWMASK ('M')) { /* mnemomic? */ if (sw & SWMASK ('M')) { /* mnemomic? */
return ssem_fprint_competition_mnemonic(of, inst); return ssem_fprint_competition_mnemonic(of, inst);
} }
return ssem_fprint_binary(of, inst, sw & SWMASK ('I') || sw & SWMASK ('M')); return ssem_fprint_binary(of, inst, sw & SWMASK ('I') || sw & SWMASK ('M'));
} }
static const char *opcode[] = { static const char *opcode[] = {
"JMP", "JRP", "LDN", "JMP", "JRP", "LDN",
"STO", "SUB", "", "STO", "SUB", "",
"CMP", "STOP", "CMP", "STOP",
NULL NULL
}; };
/* Utility function - parses decimal number. */ /* Utility function - parses decimal number. */
@ -262,16 +262,16 @@ char *start;
int n; int n;
start = cptr; start = cptr;
if (*cptr == '-') cptr++; /* skip sign */ if (*cptr == '-') cptr++; /* skip sign */
n = 0; n = 0;
while (*cptr >= '0' && *cptr <= '9') { while (*cptr >= '0' && *cptr <= '9') {
n = (n * 10) + (*cptr - '0'); n = (n * 10) + (*cptr - '0');
cptr++; cptr++;
} }
if (*start == '-') n = -n; if (*start == '-') n = -n;
if (*start) *start = 'x'; if (*start) *start = 'x';
if (*cptr) return SCPE_ARG; /* junk at end? */ if (*cptr) return SCPE_ARG; /* junk at end? */
*val = n; *val = n;
return SCPE_OK; return SCPE_OK;
@ -285,7 +285,7 @@ return SCPE_OK;
manual: manual:
"The Manchester University Small Scale Experimental Machine "The Manchester University Small Scale Experimental Machine
Programmer's Reference manual" 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) t_stat parse_sym_m (char *cptr, t_value *val)
@ -299,25 +299,25 @@ cptr = get_glyph(cptr, gbuf, 0);
if (*start) *start = 'x'; if (*start) *start = 'x';
for (n = 0; opcode[n] != NULL && strcmp(opcode[n], gbuf) != 0; n++) ; 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) { 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; a = 0;
while (*cptr >= '0' && *cptr <= '9') { while (*cptr >= '0' && *cptr <= '9') {
a = (a * 10) + (*cptr - '0'); a = (a * 10) + (*cptr - '0');
cptr++; 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; *val = (n << I_V_OP) + a;
return SCPE_OK; return SCPE_OK;
@ -335,13 +335,13 @@ start = cptr;
count = 0; count = 0;
n = 0; n = 0;
while (*cptr == '0' || *cptr == '1') { while (*cptr == '0' || *cptr == '1') {
n = n + ((*cptr - '0') << count); n = n + ((*cptr - '0') << count);
count++; count++;
cptr++; cptr++;
} }
if (*start) *start = 'x'; if (*start) *start = 'x';
if (*cptr) return SCPE_ARG; /* junk at end? */ if (*cptr) return SCPE_ARG; /* junk at end? */
*val = n; *val = n;
return SCPE_OK; return SCPE_OK;
@ -359,33 +359,33 @@ start = cptr;
count = 0; count = 0;
n = 0; n = 0;
while (*cptr == '0' || *cptr == '1') { while (*cptr == '0' || *cptr == '1') {
n = n + ((*cptr - '0') << count); n = n + ((*cptr - '0') << count);
count++; count++;
cptr++; cptr++;
} }
if (*start) *start = 'x'; if (*start) *start = 'x';
if (!(*cptr) && n > OP_UNDOCUMENTED && n <= OP_STOP) { 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; 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; count = 0;
n = 0; n = 0;
while (*cptr == '0' || *cptr == '1') { while (*cptr == '0' || *cptr == '1') {
n = n + ((*cptr - '0') << count); n = n + ((*cptr - '0') << count);
count++; count++;
cptr++; cptr++;
} }
if (n >= OP_UNDOCUMENTED) return SCPE_ARG; /* invalid instruction? */ 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; *val = (n << I_V_OP) + a;
return SCPE_OK; 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) 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? */ if (sw & SWMASK ('D')) { /* decimal? */
return parse_sym_d (cptr, val); return parse_sym_d (cptr, val);
} }
if (sw & SWMASK ('I')) { /* backward binary instruction? */ if (sw & SWMASK ('I')) { /* backward binary instruction? */
return parse_sym_i (cptr, val); return parse_sym_i (cptr, val);
} }
if (sw & SWMASK ('M')) { /* mnemonic? */ if (sw & SWMASK ('M')) { /* mnemonic? */
return parse_sym_m (cptr, val); return parse_sym_m (cptr, val);
} }
return parse_sym_b(cptr, val); /* backward binary number */ return parse_sym_b(cptr, val); /* backward binary number */
} }