remove trailing whitespace
This commit is contained in:
parent
b6a88963e5
commit
6b5c6ecceb
10
src/main.c
10
src/main.c
@ -7,7 +7,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DEBUG
|
||||
#define DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
@ -24,9 +24,9 @@ int main(int argc, char *argv[])
|
||||
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++\n+Boot: "CPU_TYPE
|
||||
" with %zu x %zu Bit RAM.+\n+++++++++++++++++++++++++++++++++++++++++++++++\n\n"
|
||||
,(sizeof(ram)/sizeof(ram[0])),sizeof(ram[0])*8);
|
||||
|
||||
|
||||
if(initialise_ram(ram,argc,argv)==-1) return 1; //load data from command line into RAM
|
||||
//(-1 in case of error,
|
||||
//(-1 in case of error,
|
||||
//else number of correct read worts)
|
||||
|
||||
while(run)
|
||||
@ -43,9 +43,9 @@ int main(int argc, char *argv[])
|
||||
printf("\ninstruction result:\n");
|
||||
|
||||
//CPU control flow
|
||||
if(execute(op_code,data_addr,ram)) //EXECUTE instruction, jump if ALU says
|
||||
if(execute(op_code,data_addr,ram)) //EXECUTE instruction, jump if ALU says
|
||||
pc=get_data(ir);
|
||||
else pc++;
|
||||
else pc++;
|
||||
|
||||
if(pc>=RAM_SIZE) pc %= RAM_SIZE; //TOY_CPU can only address 12 Bit
|
||||
|
||||
|
12
src/toy.c
12
src/toy.c
@ -47,13 +47,13 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
|
||||
//open and check the input stream
|
||||
FILE *fp;
|
||||
int j=0,int_cache=0;
|
||||
char tempS[CPU_WORD_SIZE+1]; //+1 for "\0"
|
||||
char tempS[CPU_WORD_SIZE+1]; //+1 for "\0
|
||||
|
||||
for(int i=0;i<RAM_SIZE;i++) ram[i]=0; //initialize the toy-RAM with NULL
|
||||
|
||||
if(argc<2)
|
||||
if(argc<2)
|
||||
{
|
||||
fprintf(stderr,"%s","no \".toy\" input file!\n"
|
||||
fprintf(stderr,"%s","no \".toy\" input file!\n"
|
||||
"interpretation terminated. (press -h for help)\n");
|
||||
return -1;
|
||||
}
|
||||
@ -76,13 +76,13 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
|
||||
}
|
||||
|
||||
// Fill the toy-RAM with data and break in case of error
|
||||
for(;;)
|
||||
for(;;)
|
||||
{
|
||||
for(int i = 0;i <= CPU_WORD_SIZE;i++)
|
||||
{
|
||||
int_cache = fgetc(fp);
|
||||
|
||||
if((int_cache =='\n' && i<CPU_WORD_SIZE) || (feof(fp) && i!=0))
|
||||
if((int_cache =='\n' && i<CPU_WORD_SIZE) || (feof(fp) && i!=0))
|
||||
{
|
||||
fprintf(stderr,"%s","input file has incorrect machine-word size !\n");
|
||||
fclose(fp);
|
||||
@ -129,7 +129,7 @@ int get2compl(uint16_t value)
|
||||
{
|
||||
value=(~value)+1;
|
||||
sign_value = value*(-1);
|
||||
}
|
||||
}
|
||||
return sign_value;
|
||||
}
|
||||
|
||||
|
14
src/toy.h
14
src/toy.h
@ -2,27 +2,27 @@
|
||||
#define TOY_H
|
||||
|
||||
#define CPU_TYPE "Koopman_TOY_CPU"
|
||||
#define RAM_SIZE 4096
|
||||
#define RAM_SIZE 4096
|
||||
#define CPU_WORD_SIZE 16
|
||||
|
||||
|
||||
/**
|
||||
* print_instructionSet(): print the cpu instruction set
|
||||
* This is a user help function, can be activated via
|
||||
* This is a user help function, can be activated via
|
||||
* the -h paramter.
|
||||
* Return: none
|
||||
* Return: none
|
||||
*/
|
||||
|
||||
void print_instructionSet(void);
|
||||
|
||||
/**
|
||||
* initialise_ram(): read inputstream into the toy-ram
|
||||
* Return:
|
||||
* the number of successfully read machine words,
|
||||
* Return:
|
||||
* the number of successfully read machine words,
|
||||
* -1 in case of error
|
||||
*/
|
||||
*/
|
||||
|
||||
int initialise_ram(uint16_t *ram, int argc, char **argv );
|
||||
int initialise_ram(uint16_t *ram, int argc, char **argv );
|
||||
|
||||
/**
|
||||
* get_opcode(): segments the mashine code in the OP-Code
|
||||
|
Loading…
Reference in New Issue
Block a user