#include "common.h"
#include "cpu8051.h"
#include "reg8051.h"
+#include "sfr.h"
#include "memory.h"
#include "options.h"
#include "hexfile.h"
{
int NbInst = -1; /* -1 is infinity */
if (strlen(Address) == 0) {
- printf("Invalid address\n");
+ log_err("Invalid address");
return;
}
- if (STREQ(Address, "PC"))
+ if (!STREQ(Address, "PC"))
cpu8051.pc = Ascii2Hex(Address, strlen(Address));
- if (strlen(NumberInst) != 0)
- NbInst = Ascii2Hex(NumberInst, strlen(NumberInst));
+ if (NumberInst)
+ if (strlen(NumberInst) != 0)
+ NbInst = Ascii2Hex(NumberInst, strlen(NumberInst));
InitUnixKB();
- printf("Program executing...\n");
+ log_info("Program executing...");
do {
cpu8051_Exec();
if (NbInst > 0)
NbInst--;
- } while (!IsBreakpoint(cpu8051.pc) && (NbInst != 0) && !kbhit());
+ } while (!IsBreakpoint(cpu8051.pc) && !IsStoppoint(cpu8051.pc) &&
+ (NbInst != 0) && !kbhit());
if (kbhit()) {
(void) getch(); /* Flush key */
- printf("Caught break signal!\n");
+ log_info("Caught break signal!");
}
if (NbInst == 0)
- printf("Number of instructions reached! Stopping!\n");
+ log_info("Number of instructions reached! Stopping!");
if (IsBreakpoint(cpu8051.pc))
- printf("Breakpoint hit at %.4X! Stopping!\n", cpu8051.pc);
+ log_info("Breakpoint hit at %.4X! Stopping!", cpu8051.pc);
+ if (IsStoppoint(cpu8051.pc))
+ log_info("Stoppoint hit at %.4X! Stopping!", cpu8051.pc);
ResetUnixKB();
}
for (Row = 0; Row < NumberInst ; Row++) {
Address += cpu8051_Disasm(Address, TextTmp);
printf("%s\n", TextTmp);
+
+ if (Address > 0xFFFF)
+ return;
}
}
}
}
-/* Show CPU registers */
+/* Show CPU registers, one per line */
static void
-console_show_registers(void)
+console_dump_sfr_registers_detailed(void)
+{
+ int k;
+
+ for (k = 0; k < SFR_REGS; k++) {
+ struct regwin_infos_t *regwin_infos;
+ int val;
+
+ regwin_infos = sfr_get_infos_from_row(k);
+
+ printf("%s = ", regwin_infos->name);
+
+ val = regwin_read(k);
+ if (regwin_infos->w == 2)
+ printf("$%02X", val);
+ else if (regwin_infos->w == 4)
+ printf("$%04X", val);
+
+ printf("\n");
+ }
+}
+
+/* Show CPU registers, compact format */
+static void
+console_dump_sfr_registers_compact(void)
{
unsigned char PSW = cpu8051_ReadD(_PSW_);
int BankSelect = (PSW & 0x18);
"-------\n");
}
+/* Show CPU registers */
+static void
+console_show_registers(void)
+{
+ if (options.stop_address != 0)
+ console_dump_sfr_registers_detailed();
+ else
+ console_dump_sfr_registers_compact();
+}
+
/* CPU reset and Console UI update */
static void
console_reset(void)
{
- printf("Resetting... ");
+ log_info("Resetting...");
cpu8051_Reset();
- printf("Done.\n");
- console_show_registers();
+ log_info("Done");
}
/* CPU trace and Console UI update */
{
unsigned int Index;
char *line = NULL;
-
+ int QuitRequest = 0;
char prompt[] = "-> ";
char *Title[] = { " *******************",
" Display Registers content... DR",
" Execute..................... EM [address"
" [number of instructions]]",
- " Help........................ H",
+ " Help........................ H or ?",
" Modify External Data Memory. ME address value",
" Modify Internal Data Memory. MI address value",
" Modify Program Memory....... MP address value",
" [number of instructions]",
" Reset processor............. Z", 0 };
- Index = 0;
- while (Title[Index] != 0)
- printf("%s\n", Title[Index++]);
-
- Index = 0;
- while (Menu[Index] != 0)
- printf("%s\n", Menu[Index++]);
-
console_reset();
- int QuitRequest = 0;
+ if (options.stop_address != 0) {
+ /* Automatically run program and stop at specified address. */
+ console_exec("0x0000", NULL);
+ console_show_registers();
+ QuitRequest = 1;
+ } else {
+ Index = 0;
+ while (Title[Index] != 0)
+ printf("%s\n", Title[Index++]);
+
+ Index = 0;
+ while (Menu[Index] != 0)
+ printf("%s\n", Menu[Index++]);
+
+ console_show_registers();
+ }
while (!QuitRequest) {
int slen;
goto syntax_error;
break;
case 'H':
- if (STREQ(Command, "H") && (strlen(Parameter1) == 0) &&
+ case '?':
+ if ((STREQ(Command, "H") || STREQ(Command, "?")) &&
+ (strlen(Parameter1) == 0) &&
(strlen(Parameter2) == 0)) {
Index = 0;
while (Menu[Index] != 0)