Use macro for chex

This commit is contained in:
Devine Lu Linvega 2024-05-13 14:37:21 -07:00
parent f7a2b49120
commit f88bb1f137
1 changed files with 3 additions and 12 deletions

View File

@ -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);
}