diff --git a/scp.c b/scp.c index 7f2b84a2..f27f4293 100644 --- a/scp.c +++ b/scp.c @@ -9782,9 +9782,15 @@ t_stat sprint_val (char *buffer, t_value val, uint32 radix, { #define MAX_WIDTH ((int) ((CHAR_BIT * sizeof (t_value) * 4 + 3)/3)) t_value owtest, wtest; +t_bool negative = FALSE; int32 d, digit, ndigits, commas = 0; char dbuf[MAX_WIDTH + 1]; +if (((format == PV_LEFTSIGN) || (format == PV_RCOMMASIGN)) && + (0 > (t_svalue)val)) { + val = (t_value)(-((t_svalue)val)); + negative = TRUE; + } for (d = 0; d < MAX_WIDTH; d++) dbuf[d] = (format == PV_RZRO)? '0': ' '; dbuf[MAX_WIDTH] = 0; @@ -9795,11 +9801,15 @@ do { val = val / radix; dbuf[d] = (char)((digit <= 9)? '0' + digit: 'A' + (digit - 10)); } while ((d > 0) && (val != 0)); +if (negative && (format == PV_LEFTSIGN)) + dbuf[--d] = '-'; switch (format) { case PV_LEFT: + case PV_LEFTSIGN: break; case PV_RCOMMA: + case PV_RCOMMASIGN: for (digit = 0; digit < MAX_WIDTH; digit++) if (dbuf[digit] != ' ') break; @@ -9810,6 +9820,8 @@ switch (format) { for (digit=1; digit<=commas; digit++) dbuf[MAX_WIDTH - (digit * 4)] = ','; d = d - commas; + if (negative && (format == PV_RCOMMASIGN)) + dbuf[--d] = '-'; if (width > MAX_WIDTH) { if (!buffer) return width; diff --git a/sim_defs.h b/sim_defs.h index cd04481c..e8061edf 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -418,6 +418,8 @@ typedef uint32 t_addr; #define PV_RSPC 1 /* right, space fill */ #define PV_RCOMMA 2 /* right, space fill. Comma separate every 3 */ #define PV_LEFT 3 /* left justify */ +#define PV_RCOMMASIGN 6 /* right, space fill. Comma separate every 3 treat as signed */ +#define PV_LEFTSIGN 7 /* left justify treat as signed */ /* Default timing parameters */