2023-06-10 16:15:19 +00:00
|
|
|
#include "libc/assert.h"
|
|
|
|
#include "libc/fmt/conv.h"
|
|
|
|
#include "libc/stdio/stdio.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Displays bytes as word, e.g.
|
|
|
|
*
|
2024-03-03 00:57:56 +00:00
|
|
|
* o//tool/word 6e c7 ff ff
|
2023-06-10 16:15:19 +00:00
|
|
|
* %d = -14482
|
|
|
|
* %ld = 4294952814
|
|
|
|
* %#x = 0xffffc76e
|
|
|
|
* %#lx = 0xffffc76e
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
long x;
|
|
|
|
int i, k, b;
|
|
|
|
for (x = k = 0, i = 1; i < argc; ++i) {
|
|
|
|
b = strtol(argv[i], 0, 16);
|
|
|
|
assert(0 <= b && b <= 255);
|
|
|
|
x |= (unsigned long)b << k;
|
|
|
|
k += 8;
|
|
|
|
}
|
|
|
|
printf("%%d = %d\n"
|
|
|
|
"%%ld = %ld\n"
|
|
|
|
"%%#x = %#x\n"
|
|
|
|
"%%#lx = %#lx\n",
|
|
|
|
(int)x, x, (int)x, x);
|
|
|
|
}
|