X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Femuconsole.c;h=3dcdf89e07088073010c351e5188a2eeec09f59b;hb=aae7cef39947a9456cb5c1b581e6614d4e047631;hp=e31d1b3cee6de19fb3b944d939e45a5a9ac9bdfd;hpb=b23541495010180e3a69e3e1f64c934b28775878;p=emu8051.git diff --git a/src/emuconsole.c b/src/emuconsole.c index e31d1b3..3dcdf89 100644 --- a/src/emuconsole.c +++ b/src/emuconsole.c @@ -33,6 +33,8 @@ #include "hexfile.h" #include "keyboard.h" +extern struct options_t options; + /* Capitalize all letters in buffer */ static void Capitalize(char *buffer) @@ -60,7 +62,6 @@ RemoveSpaces(char *buffer) static void console_exec(char *Address, char *NumberInst) { - char dummy; int NbInst = -1; /* -1 is infinity */ if (strlen(Address) == 0) { printf("Invalid address\n"); @@ -83,7 +84,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) @@ -224,9 +225,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]]", @@ -256,7 +257,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]; @@ -266,7 +266,7 @@ console_main(void) Parameter2[0] = '\0'; printf(prompt); - bytes_read = getline(&line, &len, stdin); + (void) getline(&line, &len, stdin); Capitalize(line); RemoveSpaces(line); @@ -325,29 +325,21 @@ 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 + 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': @@ -461,19 +453,16 @@ TooMuchParameters: int main(int argc, char **argv) { - char *hex_file; - - ParseCommandLineOptions(argc, argv); + parse_command_line_options(argc, argv); cpu8051_init(); - hex_file = get_hex_filename(); - - if (hex_file != NULL) - LoadHexFile(hex_file); + if (options.filename != NULL) + LoadHexFile(options.filename); console_main(); - printf("End of program.\n"); + + log_info("Terminate"); return 0; }