mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
preproc: implement %hs2b() and %b2hs() functions for compact binary data
Convenience preprocessor functions that allows for efficient packing of binary data in source code. Move some functions that has previously been local but are more generally useful into more accessible places. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
856ac7b7fb
commit
f6166e571a
8 changed files with 183 additions and 36 deletions
|
|
@ -292,6 +292,12 @@ int64_t readstrnum(char *str, int length, bool *warn);
|
|||
int numstr(char *buf, size_t buflen, uint64_t n,
|
||||
int digits, unsigned int base, bool ucase);
|
||||
|
||||
extern const char * const nasmlib_digit_chars[2];
|
||||
static inline const char *nasm_digit_chars(bool ucase)
|
||||
{
|
||||
return nasmlib_digit_chars[ucase];
|
||||
}
|
||||
|
||||
/*
|
||||
* seg_alloc: allocate a hitherto unused segment number.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -124,4 +124,15 @@ static inline void nasm_ctype_tasm_mode(void)
|
|||
/* No differences at the present moment */
|
||||
}
|
||||
|
||||
/* Returns a value >= 16 if not a valid hex digit */
|
||||
static inline unsigned int nasm_hexval(char c)
|
||||
{
|
||||
unsigned int v = (unsigned char) c;
|
||||
|
||||
if (v >= '0' && v <= '9')
|
||||
return v - '0';
|
||||
else
|
||||
return (v|0x20) - 'a' + 10;
|
||||
}
|
||||
|
||||
#endif /* NASM_NCTYPE_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue