X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=src%2Fpgmwin.c;h=0e8961bd0d51d92a65174cd08e80908d898416de;hb=359b0be02becb952016f0f79f6e608c7737378e7;hp=6760b665f231cf0744f496b4d7803be32d53a0c8;hpb=484f0d39a023a96309f081afa06eb90ef946d158;p=emu8051.git diff --git a/src/pgmwin.c b/src/pgmwin.c index 6760b66..0e8961b 100644 --- a/src/pgmwin.c +++ b/src/pgmwin.c @@ -220,7 +220,8 @@ pgmwin_refresh(void) int valid; GtkTreeIter iter; char str[128]; - int k; int col_id; + int k; + int col_id; int InstSize; unsigned char OpCode; @@ -239,38 +240,60 @@ 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 < 3; k++, col_id++) { + if (k < InstSize) + int2asciihex(memory_read8(PGM_MEM_ID, + Address + k), + str, 2); + else + str[0] = '\0'; - /* Display instruction menmonic. */ - cpu8051_disasm_mnemonic(OpCode, str); - gtk_list_store_set(store, &iter, COL_INST, str, -1); + gtk_list_store_set(store, &iter, col_id, 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 menmonic. */ + cpu8051_disasm_mnemonic(OpCode, str); + gtk_list_store_set(store, &iter, COL_INST, str, -1); - Address += InstSize; + /* 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; + } } }