Use macro for chex
This commit is contained in:
parent
f7a2b49120
commit
f88bb1f137
15
src/modal.c
15
src/modal.c
|
@ -13,6 +13,7 @@ static char bank_b[0x4000], *dst_ = bank_b;
|
||||||
static char *regs[0x100], stack[0x10], *stack_ = stack;
|
static char *regs[0x100], stack[0x10], *stack_ = stack;
|
||||||
|
|
||||||
#define spacer(c) (c <= ' ' || c == '(' || c == ')')
|
#define spacer(c) (c <= ' ' || c == '(' || c == ')')
|
||||||
|
#define chex(c) (0xf & (c - (c <= '9' ? '0' : 0x57)))
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
copy(char *src, char *dst, int length)
|
copy(char *src, char *dst, int length)
|
||||||
|
@ -21,16 +22,6 @@ copy(char *src, char *dst, int length)
|
||||||
return dst;
|
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 *
|
static char *
|
||||||
walk(char *s)
|
walk(char *s)
|
||||||
{
|
{
|
||||||
|
@ -98,9 +89,9 @@ device_write(char *s)
|
||||||
case 't': putc(0x09, stdout); break;
|
case 't': putc(0x09, stdout); break;
|
||||||
case 'n': putc(0x0a, stdout); break;
|
case 'n': putc(0x0a, stdout); break;
|
||||||
case 's': putc(0x20, 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
|
} else
|
||||||
putc(c, stdout);
|
putc(c, stdout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue