diff --git a/cMIPS/include/cMIPS.h b/cMIPS/include/cMIPS.h index f6791e202f0eefed026c2809912119f8951c4dcd..9a881a5605595eb567539ca0a22317dc1705d348 100644 --- a/cMIPS/include/cMIPS.h +++ b/cMIPS/include/cMIPS.h @@ -1,6 +1,6 @@ #define x_INST_BASE_ADDR 0x00000000 -#define x_DATA_BASE_ADDR 0x00020000 +#define x_DATA_BASE_ADDR 0x00010000 #define x_IO_BASE_ADDR 0x0F000000 #define x_IO_MEM_SZ 0x00002000 #define x_IO_ADDR_RANGE 0x00000020 @@ -24,7 +24,7 @@ extern void exit(int); extern void print(int); extern void to_stdout(char c); -extern int from_stdin(char *); +extern int from_stdin(void); extern void writeInt(int); extern void writeClose(void); diff --git a/cMIPS/include/cMIPS.s b/cMIPS/include/cMIPS.s index 21de4c66c27ca89cd5feb84e5d13372a7f649043..fd744cd9451a1271fddea0363c067f07fe118eac 100644 --- a/cMIPS/include/cMIPS.s +++ b/cMIPS/include/cMIPS.s @@ -3,7 +3,7 @@ .set x_INST_BASE_ADDR,0x00000000 .set x_INST_MEM_SZ,0x00004000 - .set x_DATA_BASE_ADDR,0x00020000 + .set x_DATA_BASE_ADDR,0x00010000 .set x_DATA_MEM_SZ,0x00008000 .set x_IO_BASE_ADDR,0x0F000000 diff --git a/cMIPS/include/cMIPSio.c b/cMIPS/include/cMIPSio.c index c1f74aac4eee700bc3ba85524a948bdb49e877d7..8c8103e94e84b2c70009096f04c6ab251beaefaa 100644 --- a/cMIPS/include/cMIPSio.c +++ b/cMIPS/include/cMIPSio.c @@ -16,11 +16,12 @@ //======================================================================= // simulator's STD_INPUT and STD_OUTPUT //======================================================================= -// write an integer (hex) to VHDL simulator's standard output -void print(int n) { - int *IO = (int *)IO_PRINT_ADDR; - - *IO = n; +// read a character from VHDL simulator's standard input +int from_stdin(void) { + int *IO = (void *)IO_STDIN_ADDR; + + // gets line line only after receiving a '\n' (line-feed, 0x0a) + return( *IO ); } // write a character to VHDL simulator's standard output @@ -31,21 +32,12 @@ void to_stdout(char c) { *IO = (unsigned char)c; } -// read a character from VHDL simulator's standard input -// return value = 1 if EnoOfFile, 0 otherwise -// character read is stored at address provided in argument -int from_stdin(char *c) { - int *IO = (int *)IO_STDIN_ADDR; - int status, value; - - value = *IO; - status = *(IO + 1); +// write an integer (hex) to VHDL simulator's standard output +void print(int n) { + int *IO = (int *)IO_PRINT_ADDR; - if (status == 0) { - *c = (unsigned char)value; - } - return status; -}; //-------------------------------------------------------------------- + *IO = n; +} //=======================================================================