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.
This commit is contained in:
Hugo Villeneuve
2011-12-14 03:51:00 +00:00
parent 9b40aee50b
commit dfa6052123
7 changed files with 111 additions and 61 deletions

View File

@@ -1,3 +1,13 @@
2011-12-11 Hugo Villeneuve <hugo@hugovil.com>
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 <hugo@hugovil.com>
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 <hugo@hugovil.com>
Reintroduced the console mode if no GTK+ librairies are
detected. The default is to build the GUI if GTK+ is detected,

10
NEWS
View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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");
}
}

View File

@@ -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 */