X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Femuconsole.c;h=a3f563c71c29ee7466b1e805fbf829aa891aad05;hb=c361bcde92ff71208eded7e706f25f567c1de793;hp=8073c56648af28fd9cd9954989f42bfb6fae6520;hpb=fb3b3529579773b8a14959cc6bc5bb2096fd0fe8;p=emu8051.git diff --git a/src/emuconsole.c b/src/emuconsole.c index 8073c56..a3f563c 100644 --- a/src/emuconsole.c +++ b/src/emuconsole.c @@ -33,13 +33,6 @@ #include "hexfile.h" #include "keyboard.h" -/* Maximum number of BreakPoints */ -#define MAXBP 32 - -static int RunningState; -static int NbBreakpoints; -static unsigned int Breakpoints[MAXBP]; - /* Capitalize all letters in buffer */ static void Capitalize(char *buffer) @@ -63,55 +56,10 @@ RemoveSpaces(char *buffer) strcpy(buffer, &buffer[k]); } -/* Is the a breakpoint at Address */ -static int -IsBreakpoint(unsigned int Address) -{ - int Index = 0; - while (Index < NbBreakpoints && (Breakpoints[Index] != Address)) - Index++; - - return ((Breakpoints[Index] == Address) && (Index < NbBreakpoints)); -} - -/* Show Breakpoints list */ -static void -ShowBreakpoints(void) -{ - int Index; - - for (Index = 0; Index < NbBreakpoints ; Index++) - printf("Breakpoint at Address = %.4X\n", Breakpoints[Index]); -} - -/* Clear Breakpoint at Address from list */ -static void -ClearBreakpoint(unsigned int Address) -{ - int Index = 0; - while ((Index < NbBreakpoints) && (Breakpoints[Index] != Address)) - Index++; - if (Breakpoints[Index] != Address) - return; - Breakpoints[Index] = Breakpoints[NbBreakpoints - 1]; - NbBreakpoints--; -} - -/* Set Breakpoint at Address from list */ -static void -SetBreakpoint(unsigned int Address) -{ - if (IsBreakpoint(Address)) - return; - if (NbBreakpoints < MAXBP) - Breakpoints[NbBreakpoints++] = Address; -} - /* CPU exec and Console UI update */ static void console_exec(char *Address, char *NumberInst) { - char dummy; int NbInst = -1; /* -1 is infinity */ if (strlen(Address) == 0) { printf("Invalid address\n"); @@ -134,7 +82,7 @@ console_exec(char *Address, char *NumberInst) NbInst--; } while (!IsBreakpoint(cpu8051.pc) && (NbInst != 0) && !kbhit()); if (kbhit()) { - dummy = getch(); /* Flush key */ + (void) getch(); /* Flush key */ printf("Caught break signal!\n"); } if (NbInst == 0) @@ -275,9 +223,9 @@ console_main(void) " Set Breakpoint.............. SB [address]", " Remove Breakpoint........... RB [address]", " Display Breakpoint(s)....... DB", - " Dump External Data Memory... DE [address]", - " Dump Internal Data Memory... DI [address]", - " Dump Program Memory......... DP [address]", + " Dump External Data Memory... DE [address] [size]", + " Dump Internal Data Memory... DI [address] [size]", + " Dump Program Memory......... DP [address] [size]", " Display Registers content... DR", " Execute..................... EM [address" " [number of instructions]]", @@ -307,7 +255,6 @@ console_main(void) while (!QuitRequest) { int slen; size_t len = 0; - ssize_t bytes_read; char Command[256]; char Args[256]; char Parameter1[256]; @@ -317,7 +264,7 @@ console_main(void) Parameter2[0] = '\0'; printf(prompt); - bytes_read = getline(&line, &len, stdin); + (void) getline(&line, &len, stdin); Capitalize(line); RemoveSpaces(line); @@ -375,30 +322,22 @@ console_main(void) } switch (Command[0]) { - case 'D': - if (strlen(Parameter2) == 0) { - char buf[1024]; - - if (STREQ(Command, "DB") && - (strlen(Parameter1) == 0)) - ShowBreakpoints(); - else if (STREQ(Command, "DE")) { - DumpMem(buf, Parameter1, EXT_MEM_ID); - printf(buf); - } else if (STREQ(Command, "DI")) { - DumpMem(buf, Parameter1, INT_MEM_ID); - printf(buf); - } else if (STREQ(Command, "DP")) { - if ((strlen(Parameter1) == 0)) - strcpy(Parameter1, "PC"); - DumpMem(buf, Parameter1, PGM_MEM_ID); - printf(buf); - } else if (STREQ(Command, "DR") && - (strlen(Parameter1) == 0)) - console_show_registers(); - else - goto syntax_error; - } else + case 'D': + if (STREQ(Command, "DB") && + (strlen(Parameter1) == 0)) + ShowBreakpoints(); + else if (STREQ(Command, "DE")) + DumpMem(Parameter1, Parameter2, EXT_MEM_ID); + else if (STREQ(Command, "DI")) + DumpMem(Parameter1, Parameter2, INT_MEM_ID); + else if (STREQ(Command, "DP")) { + if ((strlen(Parameter1) == 0)) + strcpy(Parameter1, "PC"); + DumpMem(Parameter1, Parameter2, PGM_MEM_ID); + } else if (STREQ(Command, "DR") && + (strlen(Parameter1) == 0)) + console_show_registers(); + else goto syntax_error; break; case 'E': @@ -518,16 +457,16 @@ main(int argc, char **argv) cpu8051_init(); - RunningState = 0; - NbBreakpoints = 0; - hex_file = get_hex_filename(); if (hex_file != NULL) LoadHexFile(hex_file); console_main(); + +#ifdef EMU8051_DEBUG printf("End of program.\n"); +#endif return 0; }