Improve user interface

- prints an OP-Code into a humen-readable word.
    - Show the content of the current pointer to a memory address.
    - Clear shell colors to be compatible with M$-Windows.
    - Delete invalid path in make-file.
This commit is contained in:
lux 2017-10-03 03:03:45 +02:00
parent 21a33681c0
commit 21b0c13056
4 changed files with 43 additions and 8 deletions

View File

@ -5,7 +5,7 @@ LDFLAGs =
DEBUG = -DNDEBUG DEBUG = -DNDEBUG
VPATH = src src/debug VPATH = src
#--------------Linker-Part----------------- #--------------Linker-Part-----------------
toy_cpu : main.o toy.o helper.o toy_cpu : main.o toy.o helper.o
echo $@ is now linked echo $@ is now linked

View File

@ -32,13 +32,16 @@ int main(int argc, char *argv[])
{ {
ir = ram[pc]; //get instruction from RAM ir = ram[pc]; //get instruction from RAM
op_code = get_opcode(ir); //determine the instruction form op_code = get_opcode(ir); //determine the instruction form
data_addr=get_data(ir); //locate the 2nd operand (ignord from OP_Code 8 to 15) data_addr=get_data(ir); /*locate the 2nd operand
(ignord from OP_Code 8 to 15)*/
//handle user output //handle user output
printf("\ninstruction: "); printf("\ninstruction:\t");
fprintBits(sizeof(*ram), ram+pc,stdout); fprintBits(sizeof(*ram), ram+pc,stdout);
printf("OP Code: %"PRIu8"\t",op_code); printf("OP CODE: %"PRIu8"\tmeans: ",op_code);
printf("Adresse: %"PRIu16"\n",data_addr); print_instruction(op_code);
printf("address: %"PRIu16"\tcontent:%"
PRIu16"\n",data_addr,ram[data_addr]);
printf("RAM position:\t%"PRIu16"\n",pc);
printf("\ninstruction result:\n"); printf("\ninstruction result:\n");
//CPU control flow //CPU control flow
@ -50,8 +53,9 @@ int main(int argc, char *argv[])
//handle user output //handle user output
printf("ACCU: %d\n",get2compl(*ACCU)); printf("ACCU: %d\n",get2compl(*ACCU));
printf("PROGRAM COUNTER: %" PRIu16 "\n",pc); printf("PROGRAM COUNTER: %" PRIu16
printf("\x1b[32m \n(n)ext step or (q)uit or (c)oredump ?\n \x1b[0m"); "\n-----------------------------------",pc);
printf("\n(n)ext step or (q)uit or (c)oredump ?\n");
//handle program flow //handle program flow
while((quit = getchar()) != '\n') while((quit = getchar()) != '\n')

View File

@ -41,6 +41,30 @@ void print_instructionSet(void)
"\tmichael.krause@uni-leipzig.de\n"); "\tmichael.krause@uni-leipzig.de\n");
} }
void print_instruction(uint8_t opcode)
{
opcode%=16;
switch(opcode)
{
case 0: printf("STORE\n"); break;
case 1: printf("LOAD\n"); break;
case 2: printf("JMP\n"); break;
case 3: printf("ADD\n"); break;
case 4: printf("SUB\n"); break;
case 5: printf("OR\n"); break;
case 6: printf("AND\n"); break;
case 7: printf("XOR\n"); break;
case 8: printf("NOT\n"); break;
case 9: printf("INC\n"); break;
case 10: printf("DEC\n"); break;
case 11: printf("ZERO\n"); break;
case 12: printf("NOP\n"); break;
case 13: printf("NOP\n"); break;
case 14: printf("NOP\n"); break;
case 15: printf("NOP\n"); break;
}
}
int initialise_ram(uint16_t *ram, int argc, char **argv ) int initialise_ram(uint16_t *ram, int argc, char **argv )
{ {

View File

@ -17,6 +17,13 @@ extern const uint16_t * const ACCU; //read only access to accu
void print_instructionSet(void); void print_instructionSet(void);
/**
* print_instruction(): converts a OP-Code into a human word.
* Return: none
*/
void print_instruction(uint8_t opcode);
/** /**
* initialise_ram(): reads inputstream into the toy-ram. * initialise_ram(): reads inputstream into the toy-ram.
* Return: * Return: