remove trailing whitespace

This commit is contained in:
lux 2017-09-27 16:25:58 +02:00
parent b6a88963e5
commit 6b5c6ecceb
3 changed files with 18 additions and 18 deletions

View File

@ -7,7 +7,7 @@
#include <assert.h> #include <assert.h>
#ifndef NDEBUG #ifndef NDEBUG
#define DEBUG #define DEBUG
#endif #endif
@ -24,9 +24,9 @@ int main(int argc, char *argv[])
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++\n+Boot: "CPU_TYPE printf("\n+++++++++++++++++++++++++++++++++++++++++++++++\n+Boot: "CPU_TYPE
" with %zu x %zu Bit RAM.+\n+++++++++++++++++++++++++++++++++++++++++++++++\n\n" " with %zu x %zu Bit RAM.+\n+++++++++++++++++++++++++++++++++++++++++++++++\n\n"
,(sizeof(ram)/sizeof(ram[0])),sizeof(ram[0])*8); ,(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 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) //else number of correct read worts)
while(run) while(run)
@ -43,9 +43,9 @@ int main(int argc, char *argv[])
printf("\ninstruction result:\n"); printf("\ninstruction result:\n");
//CPU control flow //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); pc=get_data(ir);
else pc++; else pc++;
if(pc>=RAM_SIZE) pc %= RAM_SIZE; //TOY_CPU can only address 12 Bit if(pc>=RAM_SIZE) pc %= RAM_SIZE; //TOY_CPU can only address 12 Bit

View File

@ -47,13 +47,13 @@ int initialise_ram(uint16_t *ram, int argc, char **argv )
//open and check the input stream //open and check the input stream
FILE *fp; FILE *fp;
int j=0,int_cache=0; 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 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"); "interpretation terminated. (press -h for help)\n");
return -1; 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 // Fill the toy-RAM with data and break in case of error
for(;;) for(;;)
{ {
for(int i = 0;i <= CPU_WORD_SIZE;i++) for(int i = 0;i <= CPU_WORD_SIZE;i++)
{ {
int_cache = fgetc(fp); 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"); fprintf(stderr,"%s","input file has incorrect machine-word size !\n");
fclose(fp); fclose(fp);
@ -129,7 +129,7 @@ int get2compl(uint16_t value)
{ {
value=(~value)+1; value=(~value)+1;
sign_value = value*(-1); sign_value = value*(-1);
} }
return sign_value; return sign_value;
} }

View File

@ -2,27 +2,27 @@
#define TOY_H #define TOY_H
#define CPU_TYPE "Koopman_TOY_CPU" #define CPU_TYPE "Koopman_TOY_CPU"
#define RAM_SIZE 4096 #define RAM_SIZE 4096
#define CPU_WORD_SIZE 16 #define CPU_WORD_SIZE 16
/** /**
* print_instructionSet(): print the cpu instruction set * 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. * the -h paramter.
* Return: none * Return: none
*/ */
void print_instructionSet(void); void print_instructionSet(void);
/** /**
* initialise_ram(): read inputstream into the toy-ram * initialise_ram(): read inputstream into the toy-ram
* Return: * Return:
* the number of successfully read machine words, * the number of successfully read machine words,
* -1 in case of error * -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 * get_opcode(): segments the mashine code in the OP-Code