Improve the output to help and add author.

This commit is contained in:
lux 2017-08-18 16:18:36 +02:00
parent bc97f5bd79
commit 64dfa8abbd
2 changed files with 25 additions and 17 deletions

View File

@ -43,7 +43,7 @@ int main(int argc, char *argv[])
if(execute(op_code,data_addr,ram)) //EXECUTE instruction, jump if ALU says
pc=find_data(ram[pc]);
else pc++;
if(pc>4095) pc = pc % 4096; //TOY can only address 12 Bit
if(pc>4095) pc = pc % 4096; //TOY_CPU can only address 12 Bit
//Handele user output
printf("PROGRAM COUNTER: %" PRIu16 "\n",pc);
@ -54,7 +54,12 @@ int main(int argc, char *argv[])
{
if(quit == 'c') makeHexDump(true,ram);
else if(quit == 'q') run = false;
else if(quit == 'q')
{
run = false;
printf("\nThis is an interpreter for the Koopman_TOY_CPU by\n"
"\tmichael.krause@uni-leipzig.de\n\n");
}
}
}
return 0;

View File

@ -2,7 +2,7 @@
void print_instructionSet(void)
{
printf("Boot process aborted!\n");
printf("interpretation terminated.\n");
printf("TOY-CPU Instruction Set:\n\n");
printf("OP_Code 0 (0000b):\t STORE<12 BIT ADDRESS>\n");
printf("OP_Code 1 (0001b):\t LOAD\t<12 BIT ADDRESS>\n");
@ -12,23 +12,27 @@ void print_instructionSet(void)
printf("OP_Code 5 (0101b):\t OR\t<12 BIT ADDRESS>\n");
printf("OP_Code 6 (0110b):\t AND\t<12 BIT ADDRESS>\n");
printf("OP_Code 7 (0111b):\t XOR\t<12 BIT ADDRESS>\n");
printf("OP_Code 8 (1000b):\t NOT\n");
printf("OP_Code 9 (1001b):\t INC\n");
printf("OP_Code 10 (1010b):\t DEC\n");
printf("OP_Code 11 (1011b):\t ZERO\n");
printf("OP_Code 12 (1100b):\t NOP\n");
printf("OP_Code 13 (1101b):\t NOP\n");
printf("OP_Code 14 (1110b):\t NOP\n");
printf("OP_Code 15 (1111b):\t NOP\n\n");
printf("OP_Code 8 (1000b):\t NOT\t<12 BIT undefined>\n");
printf("OP_Code 9 (1001b):\t INC\t<12 BIT undefined>\n");
printf("OP_Code 10 (1010b):\t DEC\t<12 BIT undefined>\n");
printf("OP_Code 11 (1011b):\t ZERO\t<12 BIT undefined>\n");
printf("OP_Code 12 (1100b):\t NOP\t<12 BIT undefined>\n");
printf("OP_Code 13 (1101b):\t NOP\t<12 BIT undefined>\n");
printf("OP_Code 14 (1110b):\t NOP\t<12 BIT undefined>\n");
printf("OP_Code 15 (1111b):\t NOP\t<12 BIT undefined>\n\n");
printf("BIT\t 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0\n"
"\t--------------------------------------\n"
printf("BIT\t|15 14 13 12|11 10 9 8 7 6 5 4 3 2 1 0|\n"
"\t---------------------------------------\n"
"\t| OP-CODE |\t\tADDRESS\t |\n"
"\t--------------------------------------\n\n");
"\t---------------------------------------\n\n");
printf("This machine has the following registers:\n"
"16 BIT Instruction Register(4 BIT OP, 12 BIT Adr)\n"
"16 BIT Accumulator\n"
"12 BIT Program Counter\n");
"12 BIT Program Counter\n\n");
printf("Example: 0001000000001010 on RAM position 0\n"
"0001 means: LOAD the content of ADDRESS 000000001010 into the ACCU\n\n");
printf("This is an interpreter for the Koopman_TOY_CPU by\n"
"\tmichael.krause@uni-leipzig.de\n");
}
//gibt Anzahl der erfolgreich gelesenen Maschinenworte zurück(-1 im Fehlerfall).
@ -117,7 +121,6 @@ int get2compl(uint16_t value)
bool execute(uint8_t op_code, int data_addr, uint16_t *ram) // jump if true
{
//Vorsicht: bool ops bei sigend int typs sind nach c99 undefiniert !
static uint16_t accu;
bool jump=false;