From 3e3d02a2f2579c0e20e2beff4e48d9f8d97bb8fc Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sun, 24 Nov 2013 19:23:57 -0500 Subject: [PATCH] Prevent dissassembling instructions past last address --- src/emuconsole.c | 3 +++ src/pgmwin.c | 67 ++++++++++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/emuconsole.c b/src/emuconsole.c index d5784b8..f29146d 100644 --- a/src/emuconsole.c +++ b/src/emuconsole.c @@ -110,6 +110,9 @@ DisasmN(unsigned int Address, int NumberInst) for (Row = 0; Row < NumberInst ; Row++) { Address += cpu8051_Disasm(Address, TextTmp); printf("%s\n", TextTmp); + + if (Address > 0xFFFF) + return; } } diff --git a/src/pgmwin.c b/src/pgmwin.c index 6760b66..2e6927a 100644 --- a/src/pgmwin.c +++ b/src/pgmwin.c @@ -239,38 +239,55 @@ pgmwin_refresh(void) return; } - /* Display breakpoints. */ - if (IsBreakpoint(Address)) - sprintf(str, "*"); - else - str[0] = '\0'; + if (Address > 0xFFFF) { + /* + * Not the most elegant solution, but it works to not + * display instructions past last address, 0xFFFF. + */ + gtk_list_store_set(store, &iter, + COL_BREAKPT, NULL, + COL_ADDR, NULL, + COL_B0, NULL, + COL_B1, NULL, + COL_B2, NULL, + COL_INST, NULL, + COL_ARGS, NULL, + COL_COLOR, NULL, + -1); + } else { + /* Display breakpoints. */ + if (IsBreakpoint(Address)) + sprintf(str, "*"); + else + str[0] = '\0'; - gtk_list_store_set(store, &iter, COL_BREAKPT, str, -1); + gtk_list_store_set(store, &iter, COL_BREAKPT, str, -1); - /* Display base address. */ - int2asciihex(Address, str, 4); + /* Display base address. */ + int2asciihex(Address, str, 4); - gtk_list_store_set(store, &iter, COL_ADDR, str, -1); + gtk_list_store_set(store, &iter, COL_ADDR, str, -1); - OpCode = memory_read8(PGM_MEM_ID, Address); - InstSize = cpu8051_get_instruction_size(OpCode); + OpCode = memory_read8(PGM_MEM_ID, Address); + InstSize = cpu8051_get_instruction_size(OpCode); - /* Display instruction hex bytes. */ - for (k = 0, col_id = COL_B0; k < InstSize; k++, col_id++) { - int2asciihex(memory_read8(PGM_MEM_ID, Address + k), - str, 2); - gtk_list_store_set(store, &iter, col_id, str, -1); - } + /* Display instruction hex bytes. */ + for (k = 0, col_id = COL_B0; k < InstSize; k++, col_id++) { + int2asciihex(memory_read8(PGM_MEM_ID, Address + k), + str, 2); + gtk_list_store_set(store, &iter, col_id, str, -1); + } - /* Display instruction menmonic. */ - cpu8051_disasm_mnemonic(OpCode, str); - gtk_list_store_set(store, &iter, COL_INST, str, -1); + /* Display instruction menmonic. */ + cpu8051_disasm_mnemonic(OpCode, str); + gtk_list_store_set(store, &iter, COL_INST, str, -1); - /* Display instruction arguments (if applicable). */ - str[0] = '\0'; - cpu8051_disasm_args(Address, str); - gtk_list_store_set(store, &iter, COL_ARGS, str, -1); + /* Display instruction arguments (if applicable). */ + str[0] = '\0'; + cpu8051_disasm_args(Address, str); + gtk_list_store_set(store, &iter, COL_ARGS, str, -1); - Address += InstSize; + Address += InstSize; + } } } -- 2.20.1