From dfa6052123128f13ca08077da18b876f75fa6c83 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Wed, 14 Dec 2011 03:51:00 +0000 Subject: [PATCH] Create two separate executables, emu8051-cli (default) and emu8051-gtk emu8051-gtk is optional and compiled only if Gtk+ is detected. Add optional size parameter when dumping memory. --- ChangeLog | 10 +++++++ NEWS | 10 +++++++ configure.ac | 2 +- src/Makefile.am | 69 +++++++++++++++++++++++++++++++++++++----------- src/emuconsole.c | 47 +++++++++++++++------------------ src/memory.c | 32 +++++++++++----------- src/memory.h | 2 +- 7 files changed, 111 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 680a55e..87ef95e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-12-11 Hugo Villeneuve + Added optional size parameter when dumping memory. + Created two separate executables, emu8051-cli (default) + and optional emu8051-gtk if Gtk+ is detected. + +2011-10-29 Hugo Villeneuve + Fixed SJMP error and improved columns and rows sizing. + Error reported and patch submitted by Pierre Ferrari + (piferr4ri at gmail.com). + 2010-03-19 Hugo Villeneuve Reintroduced the console mode if no GTK+ librairies are detected. The default is to build the GUI if GTK+ is detected, diff --git a/NEWS b/NEWS index 2aa3d32..62d9b1a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +2011-12-11: emu8051-1.1.1 has been released (from emu8051-1.1.1-rc2). + +2011-11-20: emu8051-1.1.1-rc2 has been released. + Added optional size parameter when dumping memory. + Created two separate executables, emu8051-cli (default) + and optional emu8051-gtk if Gtk+ is detected. + See the file 'ChangeLog' for further details. + +2011-10-29: emu8051-1.1.1-rc1 has been released. + Fixed SJMP error and improved columns and rows sizing 2010-03-19: emu8051-1.1.0 has been released. Reintroduced the console mode if no GTK+ librairies are diff --git a/configure.ac b/configure.ac index 9ed326d..543f7ac 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # configure.ac -- Process this file with autoconf to produce configure dnl Initialization stuff. -AC_INIT(emu8051, 1.1.0) +AC_INIT(emu8051, 1.1.1) AC_CONFIG_AUX_DIR(config) AC_CONFIG_SRCDIR(src/cpu8051.c) AM_CONFIG_HEADER(config.h:config-h.in) diff --git a/src/Makefile.am b/src/Makefile.am index 1c8beaf..40d1acb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,25 +5,54 @@ INCLUDES = \ -I$(top_srcdir)/pixmaps \ $(GTK_CFLAGS) -bin_PROGRAMS = emu8051 +bin_PROGRAMS = emu8051-cli -# instructions_8051.c must be first, because it and other files (instructions_8051.h and -# disasm.h) are automatically generated by a perl script, and other source files include -# them (the .h). -emu8051_SOURCES = instructions_8051.c options.c hexfile.c cpu8051.c memory.c +# instructions_8051.c must be first, because it and other files +# (instructions_8051.h and disasm.h) are automatically generated by a perl +# script, and other source files include them (the .h). +common_SOURCES = \ + instructions_8051.c \ + options.c \ + options.h \ + hexfile.c \ + hexfile.h \ + cpu8051.c \ + cpu8051.h \ + memory.c \ + memory.h \ + common.h \ + reg8051.h if USE_GTK - emu8051_SOURCES += emugtk.c memwin.c pgmwin.c regwin.c filemenu.c viewmenu.c helpmenu.c messagebox.c - emu8051_LDADD = $(GTK_LIBS) -else - emu8051_SOURCES += emuconsole.c keyboard.c + bin_PROGRAMS += emu8051-gtk + + emu8051_gtk_SOURCES = \ + $(common_SOURCES) \ + emugtk.c \ + emugtk.h \ + memwin.c \ + memwin.h \ + pgmwin.c \ + pgmwin.h \ + regwin.c \ + regwin.h \ + filemenu.c \ + filemenu.h \ + viewmenu.c \ + viewmenu.h \ + helpmenu.c \ + helpmenu.h \ + messagebox.c \ + messagebox.h \ + gtksizes.h + emu8051_gtk_LDADD = $(GTK_LIBS) endif -# These headers will be included in the distribution tarball, but will not be -# installed by 'make install' -noinst_HEADERS = common.h emugtk.h memwin.h pgmwin.h regwin.h filemenu.h viewmenu.h helpmenu.h \ - messagebox.h options.h hexfile.h cpu8051.h memory.h reg8051.h gtksizes.h \ - keyboard.h +emu8051_cli_SOURCES = \ + $(common_SOURCES) \ + emuconsole.c \ + keyboard.c \ + keyboard.h # These files are generated automatically by a perl script. instructions_8051.c instructions_8051.h disasm.h : opcode2c.pl opcodes.lst @@ -33,6 +62,14 @@ CLEANFILES = *~ DISTCLEANFILES = .deps/*.P -MAINTAINERCLEANFILES = Makefile.in instructions_8051.c instructions_8051.h disasm.h +MAINTAINERCLEANFILES = \ + Makefile.in \ + instructions_8051.c \ + instructions_8051.h \ + disasm.h -EXTRA_DIST = opcode2c.pl opcodes.lst instructions_8051.h disasm.h +EXTRA_DIST = \ + opcode2c.pl \ + opcodes.lst \ + instructions_8051.h \ + disasm.h diff --git a/src/emuconsole.c b/src/emuconsole.c index e31d1b3..b8c3bc3 100644 --- a/src/emuconsole.c +++ b/src/emuconsole.c @@ -224,9 +224,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]]", @@ -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': @@ -473,7 +465,10 @@ main(int argc, char **argv) LoadHexFile(hex_file); console_main(); + +#ifdef EMU8051_DEBUG printf("End of program.\n"); +#endif return 0; } diff --git a/src/memory.c b/src/memory.c index 0b69e32..bf3a822 100644 --- a/src/memory.c +++ b/src/memory.c @@ -110,12 +110,11 @@ memory_read8(int memory_id, unsigned long address) /* Dump memory */ void -DumpMem(char *buf, char *Address, int memory_id) +DumpMem(char *Address, char *Asize, int memory_id) { unsigned int MemAddress; + int size; int Offset, Column; - int size = 256; - int k = 0; if (strlen(Address) != 0) { if (STREQ(Address, "PC")) @@ -126,33 +125,32 @@ DumpMem(char *buf, char *Address, int memory_id) MemAddress = 0; } + if (strlen(Asize) != 0) { + size = Ascii2Hex(Asize, strlen(Asize)); + } else { + size = 256; /* Default size if not specified. */ + } + for (Offset = 0; Offset < size; Offset += 16) { unsigned char data[16]; - sprintf(&buf[k], "%.4X ", MemAddress + Offset); - k = strlen(buf); + printf("%.4X ", MemAddress + Offset); for (Column = 0; Column < 16; Column++) { data[Column] = memory_read8(memory_id, MemAddress + Offset + Column); - sprintf(&buf[k], " %.2X", (int) data[Column]); - k = strlen(buf); + printf(" %.2X", (int) data[Column]); } - sprintf(&buf[k], " "); - k = strlen(buf); + printf(" "); /* Display any ASCII characters */ for (Column = 0; Column < 16; Column++) { if ((int) data[Column] >= 32 && (int) data[Column] <= 126) { - sprintf(&buf[k], "%c", data[Column]); - k = strlen(buf); - } else { - sprintf(&buf[k], "."); - k = strlen(buf); - } + printf("%c", data[Column]); + } else + printf("."); } - sprintf(&buf[k], "\n"); - k = strlen(buf); + printf("\n"); } } diff --git a/src/memory.h b/src/memory.h index 892e17a..bd3420e 100644 --- a/src/memory.h +++ b/src/memory.h @@ -37,6 +37,6 @@ u_int8_t memory_read8(int memory_id, unsigned long address); void -DumpMem(char *buf, char *Address, int memory_id); +DumpMem(char *Address, char *Asize, int memory_id); #endif /* MEMORY_H */ -- 2.20.1