From f88bb1f137a20d5c9138289eb10571ab5c6af1c0 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 13 May 2024 14:37:21 -0700 Subject: [PATCH] Use macro for chex --- src/modal.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/modal.c b/src/modal.c index e74ec10..13a886c 100644 --- a/src/modal.c +++ b/src/modal.c @@ -13,6 +13,7 @@ static char bank_b[0x4000], *dst_ = bank_b; static char *regs[0x100], stack[0x10], *stack_ = stack; #define spacer(c) (c <= ' ' || c == '(' || c == ')') +#define chex(c) (0xf & (c - (c <= '9' ? '0' : 0x57))) static char * copy(char *src, char *dst, int length) @@ -21,16 +22,6 @@ copy(char *src, char *dst, int length) return dst; } -int -chex(char c) -{ - c -= 0x30; - if(c < 10) return c; - c -= 0x31; - if(c < 6) return 10 + c; - return 0; -} - static char * walk(char *s) { @@ -98,9 +89,9 @@ device_write(char *s) case 't': putc(0x09, stdout); break; case 'n': putc(0x0a, stdout); break; case 's': putc(0x20, stdout); break; - default: putc(sint(--s), stdout), s = walk(s); + default: putc(sint(--s), stdout), s = walk(s); } - + } else putc(c, stdout); }