diff options
Diffstat (limited to 'listing.c')
-rw-r--r-- | listing.c | 62 |
1 files changed, 39 insertions, 23 deletions
@@ -13,6 +13,7 @@ #include <stddef.h> #include <string.h> #include <ctype.h> +#include <inttypes.h> #include "nasm.h" #include "nasmlib.h" @@ -30,19 +31,19 @@ static struct MacroInhibit { int inhibiting; } *mistack; -static char xdigit[] = "0123456789ABCDEF"; +static int8_t xdigit[] = "0123456789ABCDEF"; #define HEX(a,b) (*(a)=xdigit[((b)>>4)&15],(a)[1]=xdigit[(b)&15]); -static char listline[LIST_MAX_LEN]; +static int8_t listline[LIST_MAX_LEN]; static int listlinep; -static char listdata[2 * LIST_INDENT]; /* we need less than that actually */ -static long listoffset; +static int8_t listdata[2 * LIST_INDENT]; /* we need less than that actually */ +static int32_t listoffset; -static long listlineno; +static int32_t listlineno; -static long listp; +static int32_t listp; static int suppress; /* for INCBIN & TIMES special cases */ @@ -77,7 +78,7 @@ static void list_emit(void) listdata[0] = '\0'; } -static void list_init(char *fname, efunc error) +static void list_init(int8_t *fname, efunc error) { listfp = fopen(fname, "w"); if (!listfp) { @@ -111,7 +112,7 @@ static void list_cleanup(void) fclose(listfp); } -static void list_out(long offset, char *str) +static void list_out(int32_t offset, int8_t *str) { if (strlen(listdata) + strlen(str) > LIST_HEXBIT) { strcat(listdata, "-"); @@ -122,9 +123,9 @@ static void list_out(long offset, char *str) strcat(listdata, str); } -static void list_output(long offset, const void *data, unsigned long type) +static void list_output(int32_t offset, const void *data, uint32_t type) { - unsigned long typ, size; + uint32_t typ, size; if (!listp || suppress || user_nolist) /* fbk - 9/2/00 */ return; @@ -132,9 +133,10 @@ static void list_output(long offset, const void *data, unsigned long type) typ = type & OUT_TYPMASK; size = type & OUT_SIZMASK; + if (typ == OUT_RAWDATA) { - unsigned char const *p = data; - char q[3]; + uint8_t const *p = data; + int8_t q[3]; while (size--) { HEX(q, *p); q[2] = '\0'; @@ -142,9 +144,9 @@ static void list_output(long offset, const void *data, unsigned long type) p++; } } else if (typ == OUT_ADDRESS) { - unsigned long d = *(long *)data; - char q[11]; - unsigned char p[4], *r = p; + uint64_t d = *(int64_t *)data; + int8_t q[20]; + uint8_t p[8], *r = p; if (size == 4) { q[0] = '['; q[9] = ']'; @@ -155,6 +157,20 @@ static void list_output(long offset, const void *data, unsigned long type) HEX(q + 5, p[2]); HEX(q + 7, p[3]); list_out(offset, q); + } else if (size == 8) { + q[0] = '['; + q[17] = ']'; + q[18] = '\0'; + WRITEDLONG(r, d); + HEX(q + 1, p[0]); + HEX(q + 3, p[1]); + HEX(q + 5, p[2]); + HEX(q + 7, p[3]); + HEX(q + 9, p[4]); + HEX(q + 11, p[5]); + HEX(q + 13, p[6]); + HEX(q + 15, p[7]); + list_out(offset, q); } else { q[0] = '['; q[5] = ']'; @@ -165,9 +181,9 @@ static void list_output(long offset, const void *data, unsigned long type) list_out(offset, q); } } else if (typ == OUT_REL2ADR) { - unsigned long d = *(long *)data; - char q[11]; - unsigned char p[4], *r = p; + uint32_t d = *(int32_t *)data; + int8_t q[11]; + uint8_t p[4], *r = p; q[0] = '('; q[5] = ')'; q[6] = '\0'; @@ -176,9 +192,9 @@ static void list_output(long offset, const void *data, unsigned long type) HEX(q + 3, p[1]); list_out(offset, q); } else if (typ == OUT_REL4ADR) { - unsigned long d = *(long *)data; - char q[11]; - unsigned char p[4], *r = p; + uint32_t d = *(int32_t *)data; + int8_t q[11]; + uint8_t p[4], *r = p; q[0] = '('; q[9] = ')'; q[10] = '\0'; @@ -189,13 +205,13 @@ static void list_output(long offset, const void *data, unsigned long type) HEX(q + 7, p[3]); list_out(offset, q); } else if (typ == OUT_RESERVE) { - char q[20]; + int8_t q[20]; snprintf(q, sizeof(q), "<res %08lX>", size); list_out(offset, q); } } -static void list_line(int type, char *line) +static void list_line(int type, int8_t *line) { if (!listp) return; |