From 5e5299c456428d01bf9a07b1e00f26d9fa51757a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Mon, 30 Dec 2013 10:22:33 +0000 Subject: [PATCH] added sprintf() to x86emu/debug.c --- util/bas_printf.c | 2 +- x86emu/debug.c | 42 ++++++++---------------------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/util/bas_printf.c b/util/bas_printf.c index ad63580..bfe67ac 100644 --- a/util/bas_printf.c +++ b/util/bas_printf.c @@ -352,7 +352,7 @@ static void doprnt(void (*addchar)(int), const char *sfmt, va_list ap) static char *xstring, *xestring; -static void xaddchar(int c) +void xaddchar(int c) { if (xestring == xstring) *xstring = '\0'; diff --git a/x86emu/debug.c b/x86emu/debug.c index d4f9470..7df3dba 100644 --- a/x86emu/debug.c +++ b/x86emu/debug.c @@ -154,17 +154,17 @@ void x86emu_check_mem_access(uint32_t dummy) /* check bounds, etc */ } -void x86emu_check_data_access (unsigned int dummy1, unsigned int dummy2) +void x86emu_check_data_access(unsigned int dummy1, unsigned int dummy2) { /* check bounds, etc */ } -void x86emu_inc_decoded_inst_len (int x) +void x86emu_inc_decoded_inst_len(int x) { M.x86.enc_pos += x; } -void x86emu_decode_printf (char *x) +void x86emu_decode_printf(char *x) { #ifdef DBG_X86EMU strcpy(x, &M.x86.decoded_buf[M.x86.enc_str_pos & 127]); @@ -172,44 +172,18 @@ void x86emu_decode_printf (char *x) #endif } -void x86emu_decode_printf2 (char *x, int y) +void x86emu_decode_printf2(char *x, int y) { char temp[100], *p; - doprnt(xaddchar, x, y); #ifdef DBG_X86EMU - { - p = temp; - while (x[0] != 0) - { - if (x[0] =='%' && x[1] =='d') - { - x += 2; - Funcs_ltoa(p, y, 10); - while (p[0] != 0) - p++; - } - else if (x[0] == '%' && x[1] == 'x') - { - x += 2; - *p++ = '0'; - *p++ = 'x'; - y &= 0xffff; - Funcs_ltoa(p, y, 16); - while (p[0] != 0) - p++; - } - else - *p++ = *x++; - } - *p = 0; - strcpy(temp, &M.x86.decoded_buf[M.x86.enc_str_pos & 127]); - M.x86.enc_str_pos += strlen(temp); - } + sprintf(temp, x, y); + strcpy(temp, &M.x86.decoded_buf[M.x86.enc_str_pos & 127]); + M.x86.enc_str_pos += strlen(temp); #endif } -void x86emu_end_instr (void) +void x86emu_end_instr(void) { M.x86.enc_str_pos = 0; M.x86.enc_pos = 0;