+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,
+ but the console mode can always be forced by using
+ "--enable-gui=no" as a configure option.
+
2009-02-09 Hugo Villeneuve <hugo@hugovil.com>
* Updated Free Software Foundation address.
+2010-03-19: emu8051-1.1.0 has been released.
+ Reintroduced the console mode if no GTK+ librairies are
+ detected.
+
2009-02-09: emu8051-1.0.2 has been released.
Updated Free Software Foundation address.
/* Maximum number of BreakPoints */
#define MAXBP 32
-#define ENDLINE "\n"
-
static int RunningState;
static int NbBreakpoints;
static unsigned int Breakpoints[MAXBP];
DisasmN(MemAddress, NbInst);
}
-/* Dump memory */
-static void
-DumpMem(char *Address, int memory_id)
-{
- unsigned int MemAddress;
- int Offset, Column;
- int size = 256;
-
- if (strlen(Address) != 0) {
- if (STREQ(Address, "PC"))
- MemAddress = cpu8051.pc;
- else
- MemAddress = Ascii2Hex(Address, strlen(Address));
- } else {
- MemAddress = 0;
- }
-
- for (Offset = 0; Offset < size; Offset += 16) {
- unsigned char data[16];
-
- printf("%.4X ", MemAddress + Offset);
- for (Column = 0; Column < 16; Column++) {
- data[Column] = memory_read8(memory_id, MemAddress +
- Offset + Column);
- printf(" %.2X", (int) data[Column]);
- }
- printf(" ");
-
- /* Display any ASCII characters */
- for (Column = 0; Column < 16; Column++) {
- if ((int) data[Column] >= 32 &&
- (int) data[Column] <= 126)
- printf("%c", data[Column]);
- else
- printf(".");
- }
- printf("\n");
- }
-}
-
/* Set NewValue to Register */
static void
SetRegister(char *Register, char *NewValue)
else if (STREQ(Register, "SP"))
cpu8051_WriteD(_SP_, Ascii2Hex(NewValue, 2));
else {
- printf("%sInvalid register name!%s", ENDLINE, ENDLINE);
+ printf("\nInvalid register name!\n");
printf("Valid registers are A, B, PC and SP.\n");
}
}
Index = 0;
while (Title[Index] != 0)
- printf("%s%s", Title[Index++], ENDLINE);
+ printf("%s\n", Title[Index++]);
Index = 0;
while (Menu[Index] != 0)
- printf("%s%s", Menu[Index++], ENDLINE);
+ printf("%s\n", Menu[Index++]);
console_reset();
}
switch (Command[0]) {
- case 'D':
+ case 'D':
if (strlen(Parameter2) == 0) {
+ char buf[1024];
+
if (STREQ(Command, "DB") &&
(strlen(Parameter1) == 0))
ShowBreakpoints();
- else if (STREQ(Command, "DE"))
- DumpMem(Parameter1, EXT_MEM_ID);
- else if (STREQ(Command, "DI"))
- DumpMem(Parameter1, INT_MEM_ID);
- else if (STREQ(Command, "DP")) {
+ 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(Parameter1, PGM_MEM_ID);
+ DumpMem(buf, Parameter1, PGM_MEM_ID);
+ printf(buf);
} else if (STREQ(Command, "DR") &&
(strlen(Parameter1) == 0))
console_show_registers();
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
cpu8051_Reset( );
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
cpu8051_Exec();
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
RunningState = 0;
regwin_Show();
pgmwin_Disasm();
- memwin_DumpD( 0 );
+ memwin_DumpD("0x00");
}
}
*/
#include <stdio.h>
+#include <string.h>
+#include "common.h"
+#include "cpu8051.h"
+#include "hexfile.h"
#include "memory.h"
#define PGM_MEM_SIZE 65536
break;
}
}
+
+/* Dump memory */
+void
+DumpMem(char *buf, char *Address, int memory_id)
+{
+ unsigned int MemAddress;
+ int Offset, Column;
+ int size = 256;
+ int k = 0;
+
+ if (strlen(Address) != 0) {
+ if (STREQ(Address, "PC"))
+ MemAddress = cpu8051.pc;
+ else
+ MemAddress = Ascii2Hex(Address, strlen(Address));
+ } else {
+ MemAddress = 0;
+ }
+
+ for (Offset = 0; Offset < size; Offset += 16) {
+ unsigned char data[16];
+
+ sprintf(&buf[k], "%.4X ", MemAddress + Offset);
+ k = strlen(buf);
+
+ 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);
+ }
+ sprintf(&buf[k], " ");
+ k = strlen(buf);
+
+ /* 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);
+ }
+ }
+ sprintf(&buf[k], "\n");
+ k = strlen(buf);
+ }
+}
u_int8_t
memory_read8( int memory_id, unsigned long address );
+void
+DumpMem(char *buf, char *Address, int memory_id);
+
#endif /* MEMORY_H */
#include <stdio.h>
#include "common.h"
+#include "memory.h"
+#include "hexfile.h"
#include "cpu8051.h"
#include "memwin.h"
-
static GtkWidget *memclist;
-
GtkWidget *
memwin_init( int width, int height )
{
/* Dump 16 rows of 16 bytes from Address in Memory (direct addressing) */
void
-memwin_DumpD( unsigned int Address )
+memwin_DumpD(char *MemAddress)
{
- char TextTmp[255];
+ char TextTmp[1024];
int row, column, TextLength;
+ unsigned int Address;
+
+ if (strlen(MemAddress) != 0) {
+ if (STREQ(MemAddress, "PC"))
+ Address = cpu8051.pc;
+ else
+ Address = Ascii2Hex(MemAddress, strlen(MemAddress));
+ } else {
+ Address = 0;
+ }
gtk_clist_freeze( GTK_CLIST( memclist ) );
+
for ( row = 0; row < 16; row++ ) {
sprintf( TextTmp, "%.4X", Address );
gtk_clist_set_text( GTK_CLIST( memclist ), row, 0, TextTmp );
gtk_clist_select_row( GTK_CLIST( memclist ), 0, 0 );
gtk_clist_thaw( GTK_CLIST( memclist ) );
}
-
-
-/* Dump 16 rows of 16 bytes from Address in Memory (indirect addressing) */
-void
-memwin_DumpI( unsigned int Address )
-{
- char TextTmp[255];
- int row, column, TextLength;
-
- gtk_clist_freeze( GTK_CLIST( memclist ) );
- for ( row = 0; row < 16; row++ ) {
- sprintf( TextTmp, "%.4X", Address );
- gtk_clist_set_text( GTK_CLIST( memclist ), row, 0, TextTmp );
-
- for ( column = 0; column < 16; column++ ) {
- sprintf( TextTmp, "%.2X", ( int ) cpu8051_ReadI( Address + column ) );
- gtk_clist_set_text( GTK_CLIST( memclist ), row, column + 1, TextTmp );
- }
-
- TextLength = 0;
- for ( column = 0; column < 16; column++ ) {
- if ( ( ( int ) cpu8051_ReadI( Address + column ) >= 32 ) && ( ( int ) cpu8051_ReadI( Address + column ) <= 126 ) )
- TextLength += sprintf( &TextTmp[ TextLength ], "%c", cpu8051_ReadI( Address + column ) );
- else TextLength += sprintf( &TextTmp[ TextLength ], "." );
- }
- gtk_clist_set_text( GTK_CLIST( memclist ), row, 17, TextTmp );
-
- Address += 16;
- }
- gtk_clist_thaw( GTK_CLIST( memclist ) );
-}
#ifndef MEMWIN_H
#define MEMWIN_H 1
-
#include <gtk/gtk.h>
-
GtkWidget *
-memwin_init( int width, int height );
+memwin_init(int width, int height);
void
-memwin_DumpD( unsigned int Address );
-
-void
-memwin_DumpI( unsigned int Address );
-
+memwin_DumpD(char *Address);
#endif /* MEMWIN_H */