|
|
|
@ -61,7 +61,7 @@ inline void hex02(std::uint8_t byte, char buffer[2])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<std::size_t N>
|
|
|
|
|
inline __attribute((always_inline)) void print_exact(const char* ar)
|
|
|
|
|
inline __attribute__((always_inline)) void print_exact(const char* ar)
|
|
|
|
|
{
|
|
|
|
|
fwrite(ar, 1, N, stdout);
|
|
|
|
|
}
|
|
|
|
@ -75,17 +75,6 @@ inline __attribute__((always_inline)) void print_exact(const char (&ar)[N])
|
|
|
|
|
inline static void u64_to_hex(std::uint64_t num, char* s)
|
|
|
|
|
{
|
|
|
|
|
hv::lookup_hex_string(num, s);
|
|
|
|
|
#if 0
|
|
|
|
|
std::uint64_t x = num;
|
|
|
|
|
x = ((x & 0xFFFF) << 32) | ((x & 0xFFFF0000) >> 16);
|
|
|
|
|
x = ((x & 0x0000FF000000FF00) >> 8) | (x & 0x000000FF000000FF) << 16;
|
|
|
|
|
x = ((x & 0x00F000F000F000F0) >> 4) | (x & 0x000F000F000F000F) << 8;
|
|
|
|
|
|
|
|
|
|
uint64_t mask = ((x + 0x0606060606060606) >> 4) & 0x0101010101010101;
|
|
|
|
|
x += 0x27 * mask;
|
|
|
|
|
|
|
|
|
|
*(uint64_t *)s = x;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace hv {
|
|
|
|
@ -99,26 +88,28 @@ namespace hv {
|
|
|
|
|
#define S
|
|
|
|
|
#define P_EX(n, buf) print_exact(buf)
|
|
|
|
|
#endif
|
|
|
|
|
char posbuf[3 + 16 + 2] = { '0' };
|
|
|
|
|
char posbuf[3 + 16 + 2];
|
|
|
|
|
posbuf[0] = '\n';
|
|
|
|
|
posbuf[1] = '0';
|
|
|
|
|
posbuf[2] = 'x';
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
std::memset(posbuf+3, '0', 16);
|
|
|
|
|
#endif
|
|
|
|
|
posbuf[3 + 16] = ' ';
|
|
|
|
|
posbuf[3 + 16 + 1] = ' ';
|
|
|
|
|
|
|
|
|
|
u64_to_hex(offset, posbuf+3);
|
|
|
|
|
prints(posbuf+1);
|
|
|
|
|
|
|
|
|
|
char hxbuf[3];
|
|
|
|
|
char hxbuf[3] = { ' ', ' ', ' ' };
|
|
|
|
|
std::size_t i=0;
|
|
|
|
|
char r_ascii[2 + ROW_SZ];
|
|
|
|
|
r_ascii[0] = ' ';
|
|
|
|
|
r_ascii[1] = ' ';
|
|
|
|
|
char* ascii = r_ascii + 2;
|
|
|
|
|
const auto memsize = memory.size();
|
|
|
|
|
|
|
|
|
|
hxbuf[2] = ' ';
|
|
|
|
|
for(;i<memory.size();i++) {
|
|
|
|
|
for(;i<memsize;i++) {
|
|
|
|
|
if (i && i % ROW_SZ == 0) { //TODO: Change to i +=16 so we don't have to branch here on every byte. Make sure to not overrun buffer tho
|
|
|
|
|
P_EX(S, r_ascii);
|
|
|
|
|
|
|
|
|
@ -131,9 +122,9 @@ namespace hv {
|
|
|
|
|
|
|
|
|
|
ascii[i%ROW_SZ] = ascii_map[idx];
|
|
|
|
|
}
|
|
|
|
|
if (memory.size() % ROW_SZ != 0)
|
|
|
|
|
if (memsize % ROW_SZ != 0)
|
|
|
|
|
{
|
|
|
|
|
auto rest = memory.size() % ROW_SZ;
|
|
|
|
|
auto rest = memsize % ROW_SZ;
|
|
|
|
|
ascii[rest] = 0;
|
|
|
|
|
constexpr const char output[3] = { ' ', ' ', ' ' };
|
|
|
|
|
for(std::size_t j=0;j< ROW_SZ - rest;j++)
|
|
|
|
|