From fb3017e3e231f88bcc50265b17343edb919dae5c Mon Sep 17 00:00:00 2001 From: David Brown Date: Sun, 11 Dec 2016 17:19:18 +0000 Subject: [PATCH] Update bootstrap C source. --- bootstrap/unix-44/Files.c | 4 +- bootstrap/unix-44/Out.c | 77 ++++++++++++++++++++++++++++++++++++ bootstrap/unix-44/Out.h | 3 ++ bootstrap/unix-44/Texts.c | 15 ++++--- bootstrap/unix-48/Files.c | 4 +- bootstrap/unix-48/Out.c | 77 ++++++++++++++++++++++++++++++++++++ bootstrap/unix-48/Out.h | 3 ++ bootstrap/unix-48/Texts.c | 15 ++++--- bootstrap/unix-88/Files.c | 4 +- bootstrap/unix-88/Out.c | 77 ++++++++++++++++++++++++++++++++++++ bootstrap/unix-88/Out.h | 3 ++ bootstrap/unix-88/Texts.c | 15 ++++--- bootstrap/windows-48/Files.c | 4 +- bootstrap/windows-48/Out.c | 77 ++++++++++++++++++++++++++++++++++++ bootstrap/windows-48/Out.h | 3 ++ bootstrap/windows-48/Texts.c | 15 ++++--- bootstrap/windows-88/Files.c | 4 +- bootstrap/windows-88/Out.c | 77 ++++++++++++++++++++++++++++++++++++ bootstrap/windows-88/Out.h | 3 ++ bootstrap/windows-88/Texts.c | 15 ++++--- 20 files changed, 455 insertions(+), 40 deletions(-) diff --git a/bootstrap/unix-44/Files.c b/bootstrap/unix-44/Files.c index c9994206..652cb128 100644 --- a/bootstrap/unix-44/Files.c +++ b/bootstrap/unix-44/Files.c @@ -172,7 +172,7 @@ void Files_DumpFile (Files_File f, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"next: ", 15); - Out_Int((INT32)(ADDRESS)f->next, 1); + Out_Hex((INT32)(ADDRESS)f->next, 1); Out_Ln(); } @@ -196,8 +196,8 @@ void Files_DumpBuffer (Files_Buffer b, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"data: ", 7); - Out_String((CHAR*)"...", 4); Out_Ln(); + Out_HexDump((void*)b->data, 4096); Files_Spaces(indent); Out_String((CHAR*)"f: ", 7); if (b->f == NIL) { diff --git a/bootstrap/unix-44/Out.c b/bootstrap/unix-44/Out.c index a647f77d..38e680ae 100644 --- a/bootstrap/unix-44/Out.c +++ b/bootstrap/unix-44/Out.c @@ -16,6 +16,9 @@ static INT16 Out_in; export void Out_Char (CHAR ch); export void Out_Flush (void); +export void Out_Hex (INT64 x, INT64 n); +export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +export void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l); export void Out_Int (INT64 x, INT64 n); static INT32 Out_Length (CHAR *s, ADDRESS s__len); export void Out_Ln (void); @@ -119,12 +122,86 @@ void Out_Int (INT64 x, INT64 n) } } +void Out_Hex (INT64 x, INT64 n) +{ + if (n < 1) { + n = 1; + } else if (n > 16) { + n = 16; + } + while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) { + n += 1; + } + x = __ROT(x, __ASHL(16 - n, 2), 64); + while (n > 0) { + x = __ROTL(x, 4, 64); + n -= 1; + if (__MASK(x, -16) < 10) { + Out_Char((CHAR)(__MASK(x, -16) + 48)); + } else { + Out_Char((CHAR)((__MASK(x, -16) - 10) + 65)); + } + } +} + void Out_Ln (void) { Out_String(Platform_NL, 3); Out_Flush(); } +void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l) +{ + INT32 i, n, lim; + CHAR c; + lim = a + l; + while (a < lim) { + if (a + 16 < lim) { + n = 16; + } else { + n = lim - a; + } + Out_Hex(o, 8); + Out_Char(' '); + i = 0; + while (i < n) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + __GET(a + i, c, CHAR); + Out_Hex((INT16)c, 2); + Out_Char(' '); + i += 1; + } + while (i < 16) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + Out_String((CHAR*)" ", 4); + i += 1; + } + Out_String((CHAR*)" ", 2); + i = 0; + while (i < n) { + __GET(a + i, c, CHAR); + if ((INT16)c < 32 || (INT16)c > 126) { + Out_Char('.'); + } else { + Out_Char(c); + } + i += 1; + } + a += n; + o += n; + Out_Ln(); + } +} + +void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) +{ + Out_HexDumpAdr((ADDRESS)m, 0, m__len); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; diff --git a/bootstrap/unix-44/Out.h b/bootstrap/unix-44/Out.h index 8c7a5774..bae3e220 100644 --- a/bootstrap/unix-44/Out.h +++ b/bootstrap/unix-44/Out.h @@ -11,6 +11,9 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); import void Out_Flush (void); +import void Out_Hex (INT64 x, INT64 n); +import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +import void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l); import void Out_Int (INT64 x, INT64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, INT16 n); diff --git a/bootstrap/unix-44/Texts.c b/bootstrap/unix-44/Texts.c index 35e17988..d86402c1 100644 --- a/bootstrap/unix-44/Texts.c +++ b/bootstrap/unix-44/Texts.c @@ -243,13 +243,13 @@ static void Texts_DumpText (Texts_Text t) Out_Int(t->len, 1); Out_Ln(); Out_String((CHAR*)" notify: ", 15); - Out_Int((INT32)(ADDRESS)t->notify, 1); + Out_Hex((INT32)(ADDRESS)t->notify, 1); Out_Ln(); Out_String((CHAR*)" head: ", 15); - Out_Int((INT32)(ADDRESS)t->head, 1); + Out_Hex((INT32)(ADDRESS)t->head, 1); Out_Ln(); Out_String((CHAR*)" cache: ", 15); - Out_Int((INT32)(ADDRESS)t->cache, 1); + Out_Hex((INT32)(ADDRESS)t->cache, 1); Out_Ln(); Out_String((CHAR*)" corg: ", 15); Out_Int(t->corg, 1); @@ -265,7 +265,7 @@ static void Texts_DumpElem (Texts_Elem e) Out_Int(e->H, 1); Out_Ln(); Out_String((CHAR*)" handle: ", 13); - Out_Int((INT32)(ADDRESS)e->handle, 1); + Out_Hex((INT32)(ADDRESS)e->handle, 1); Out_Ln(); Out_String((CHAR*)" base: ", 13); if (e->base == NIL) { @@ -279,11 +279,14 @@ static void Texts_DumpElem (Texts_Elem e) static void Texts_DumpRun (Texts_Run ru) { + Out_String((CHAR*)" Run at ", 10); + Out_Hex((INT32)(ADDRESS)ru, 1); + Out_Ln(); Out_String((CHAR*)" prev: ", 12); - Out_Int((INT32)(ADDRESS)ru->prev, 1); + Out_Hex((INT32)(ADDRESS)ru->prev, 1); Out_Ln(); Out_String((CHAR*)" next: ", 12); - Out_Int((INT32)(ADDRESS)ru->next, 1); + Out_Hex((INT32)(ADDRESS)ru->next, 1); Out_Ln(); Out_String((CHAR*)" len: ", 12); Out_Int(ru->len, 1); diff --git a/bootstrap/unix-48/Files.c b/bootstrap/unix-48/Files.c index c9994206..652cb128 100644 --- a/bootstrap/unix-48/Files.c +++ b/bootstrap/unix-48/Files.c @@ -172,7 +172,7 @@ void Files_DumpFile (Files_File f, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"next: ", 15); - Out_Int((INT32)(ADDRESS)f->next, 1); + Out_Hex((INT32)(ADDRESS)f->next, 1); Out_Ln(); } @@ -196,8 +196,8 @@ void Files_DumpBuffer (Files_Buffer b, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"data: ", 7); - Out_String((CHAR*)"...", 4); Out_Ln(); + Out_HexDump((void*)b->data, 4096); Files_Spaces(indent); Out_String((CHAR*)"f: ", 7); if (b->f == NIL) { diff --git a/bootstrap/unix-48/Out.c b/bootstrap/unix-48/Out.c index a647f77d..38e680ae 100644 --- a/bootstrap/unix-48/Out.c +++ b/bootstrap/unix-48/Out.c @@ -16,6 +16,9 @@ static INT16 Out_in; export void Out_Char (CHAR ch); export void Out_Flush (void); +export void Out_Hex (INT64 x, INT64 n); +export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +export void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l); export void Out_Int (INT64 x, INT64 n); static INT32 Out_Length (CHAR *s, ADDRESS s__len); export void Out_Ln (void); @@ -119,12 +122,86 @@ void Out_Int (INT64 x, INT64 n) } } +void Out_Hex (INT64 x, INT64 n) +{ + if (n < 1) { + n = 1; + } else if (n > 16) { + n = 16; + } + while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) { + n += 1; + } + x = __ROT(x, __ASHL(16 - n, 2), 64); + while (n > 0) { + x = __ROTL(x, 4, 64); + n -= 1; + if (__MASK(x, -16) < 10) { + Out_Char((CHAR)(__MASK(x, -16) + 48)); + } else { + Out_Char((CHAR)((__MASK(x, -16) - 10) + 65)); + } + } +} + void Out_Ln (void) { Out_String(Platform_NL, 3); Out_Flush(); } +void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l) +{ + INT32 i, n, lim; + CHAR c; + lim = a + l; + while (a < lim) { + if (a + 16 < lim) { + n = 16; + } else { + n = lim - a; + } + Out_Hex(o, 8); + Out_Char(' '); + i = 0; + while (i < n) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + __GET(a + i, c, CHAR); + Out_Hex((INT16)c, 2); + Out_Char(' '); + i += 1; + } + while (i < 16) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + Out_String((CHAR*)" ", 4); + i += 1; + } + Out_String((CHAR*)" ", 2); + i = 0; + while (i < n) { + __GET(a + i, c, CHAR); + if ((INT16)c < 32 || (INT16)c > 126) { + Out_Char('.'); + } else { + Out_Char(c); + } + i += 1; + } + a += n; + o += n; + Out_Ln(); + } +} + +void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) +{ + Out_HexDumpAdr((ADDRESS)m, 0, m__len); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; diff --git a/bootstrap/unix-48/Out.h b/bootstrap/unix-48/Out.h index 8c7a5774..bae3e220 100644 --- a/bootstrap/unix-48/Out.h +++ b/bootstrap/unix-48/Out.h @@ -11,6 +11,9 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); import void Out_Flush (void); +import void Out_Hex (INT64 x, INT64 n); +import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +import void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l); import void Out_Int (INT64 x, INT64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, INT16 n); diff --git a/bootstrap/unix-48/Texts.c b/bootstrap/unix-48/Texts.c index 9016dbc8..5450b303 100644 --- a/bootstrap/unix-48/Texts.c +++ b/bootstrap/unix-48/Texts.c @@ -243,13 +243,13 @@ static void Texts_DumpText (Texts_Text t) Out_Int(t->len, 1); Out_Ln(); Out_String((CHAR*)" notify: ", 15); - Out_Int((INT32)(ADDRESS)t->notify, 1); + Out_Hex((INT32)(ADDRESS)t->notify, 1); Out_Ln(); Out_String((CHAR*)" head: ", 15); - Out_Int((INT32)(ADDRESS)t->head, 1); + Out_Hex((INT32)(ADDRESS)t->head, 1); Out_Ln(); Out_String((CHAR*)" cache: ", 15); - Out_Int((INT32)(ADDRESS)t->cache, 1); + Out_Hex((INT32)(ADDRESS)t->cache, 1); Out_Ln(); Out_String((CHAR*)" corg: ", 15); Out_Int(t->corg, 1); @@ -265,7 +265,7 @@ static void Texts_DumpElem (Texts_Elem e) Out_Int(e->H, 1); Out_Ln(); Out_String((CHAR*)" handle: ", 13); - Out_Int((INT32)(ADDRESS)e->handle, 1); + Out_Hex((INT32)(ADDRESS)e->handle, 1); Out_Ln(); Out_String((CHAR*)" base: ", 13); if (e->base == NIL) { @@ -279,11 +279,14 @@ static void Texts_DumpElem (Texts_Elem e) static void Texts_DumpRun (Texts_Run ru) { + Out_String((CHAR*)" Run at ", 10); + Out_Hex((INT32)(ADDRESS)ru, 1); + Out_Ln(); Out_String((CHAR*)" prev: ", 12); - Out_Int((INT32)(ADDRESS)ru->prev, 1); + Out_Hex((INT32)(ADDRESS)ru->prev, 1); Out_Ln(); Out_String((CHAR*)" next: ", 12); - Out_Int((INT32)(ADDRESS)ru->next, 1); + Out_Hex((INT32)(ADDRESS)ru->next, 1); Out_Ln(); Out_String((CHAR*)" len: ", 12); Out_Int(ru->len, 1); diff --git a/bootstrap/unix-88/Files.c b/bootstrap/unix-88/Files.c index 2d13a80b..92ada350 100644 --- a/bootstrap/unix-88/Files.c +++ b/bootstrap/unix-88/Files.c @@ -172,7 +172,7 @@ void Files_DumpFile (Files_File f, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"next: ", 15); - Out_Int((INT64)(ADDRESS)f->next, 1); + Out_Hex((INT64)(ADDRESS)f->next, 1); Out_Ln(); } @@ -196,8 +196,8 @@ void Files_DumpBuffer (Files_Buffer b, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"data: ", 7); - Out_String((CHAR*)"...", 4); Out_Ln(); + Out_HexDump((void*)b->data, 4096); Files_Spaces(indent); Out_String((CHAR*)"f: ", 7); if (b->f == NIL) { diff --git a/bootstrap/unix-88/Out.c b/bootstrap/unix-88/Out.c index a647f77d..64345041 100644 --- a/bootstrap/unix-88/Out.c +++ b/bootstrap/unix-88/Out.c @@ -16,6 +16,9 @@ static INT16 Out_in; export void Out_Char (CHAR ch); export void Out_Flush (void); +export void Out_Hex (INT64 x, INT64 n); +export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +export void Out_HexDumpAdr (INT64 a, INT64 o, INT64 l); export void Out_Int (INT64 x, INT64 n); static INT32 Out_Length (CHAR *s, ADDRESS s__len); export void Out_Ln (void); @@ -119,12 +122,86 @@ void Out_Int (INT64 x, INT64 n) } } +void Out_Hex (INT64 x, INT64 n) +{ + if (n < 1) { + n = 1; + } else if (n > 16) { + n = 16; + } + while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) { + n += 1; + } + x = __ROT(x, __ASHL(16 - n, 2), 64); + while (n > 0) { + x = __ROTL(x, 4, 64); + n -= 1; + if (__MASK(x, -16) < 10) { + Out_Char((CHAR)(__MASK(x, -16) + 48)); + } else { + Out_Char((CHAR)((__MASK(x, -16) - 10) + 65)); + } + } +} + void Out_Ln (void) { Out_String(Platform_NL, 3); Out_Flush(); } +void Out_HexDumpAdr (INT64 a, INT64 o, INT64 l) +{ + INT64 i, n, lim; + CHAR c; + lim = a + l; + while (a < lim) { + if (a + 16 < lim) { + n = 16; + } else { + n = lim - a; + } + Out_Hex(o, 8); + Out_Char(' '); + i = 0; + while (i < n) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + __GET(a + i, c, CHAR); + Out_Hex((INT16)c, 2); + Out_Char(' '); + i += 1; + } + while (i < 16) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + Out_String((CHAR*)" ", 4); + i += 1; + } + Out_String((CHAR*)" ", 2); + i = 0; + while (i < n) { + __GET(a + i, c, CHAR); + if ((INT16)c < 32 || (INT16)c > 126) { + Out_Char('.'); + } else { + Out_Char(c); + } + i += 1; + } + a += n; + o += n; + Out_Ln(); + } +} + +void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) +{ + Out_HexDumpAdr((ADDRESS)m, 0, m__len); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; diff --git a/bootstrap/unix-88/Out.h b/bootstrap/unix-88/Out.h index 8c7a5774..6962abdc 100644 --- a/bootstrap/unix-88/Out.h +++ b/bootstrap/unix-88/Out.h @@ -11,6 +11,9 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); import void Out_Flush (void); +import void Out_Hex (INT64 x, INT64 n); +import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +import void Out_HexDumpAdr (INT64 a, INT64 o, INT64 l); import void Out_Int (INT64 x, INT64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, INT16 n); diff --git a/bootstrap/unix-88/Texts.c b/bootstrap/unix-88/Texts.c index 1afb5eba..c7301f23 100644 --- a/bootstrap/unix-88/Texts.c +++ b/bootstrap/unix-88/Texts.c @@ -243,13 +243,13 @@ static void Texts_DumpText (Texts_Text t) Out_Int(t->len, 1); Out_Ln(); Out_String((CHAR*)" notify: ", 15); - Out_Int((INT64)(ADDRESS)t->notify, 1); + Out_Hex((INT64)(ADDRESS)t->notify, 1); Out_Ln(); Out_String((CHAR*)" head: ", 15); - Out_Int((INT64)(ADDRESS)t->head, 1); + Out_Hex((INT64)(ADDRESS)t->head, 1); Out_Ln(); Out_String((CHAR*)" cache: ", 15); - Out_Int((INT64)(ADDRESS)t->cache, 1); + Out_Hex((INT64)(ADDRESS)t->cache, 1); Out_Ln(); Out_String((CHAR*)" corg: ", 15); Out_Int(t->corg, 1); @@ -265,7 +265,7 @@ static void Texts_DumpElem (Texts_Elem e) Out_Int(e->H, 1); Out_Ln(); Out_String((CHAR*)" handle: ", 13); - Out_Int((INT64)(ADDRESS)e->handle, 1); + Out_Hex((INT64)(ADDRESS)e->handle, 1); Out_Ln(); Out_String((CHAR*)" base: ", 13); if (e->base == NIL) { @@ -279,11 +279,14 @@ static void Texts_DumpElem (Texts_Elem e) static void Texts_DumpRun (Texts_Run ru) { + Out_String((CHAR*)" Run at ", 10); + Out_Hex((INT64)(ADDRESS)ru, 1); + Out_Ln(); Out_String((CHAR*)" prev: ", 12); - Out_Int((INT64)(ADDRESS)ru->prev, 1); + Out_Hex((INT64)(ADDRESS)ru->prev, 1); Out_Ln(); Out_String((CHAR*)" next: ", 12); - Out_Int((INT64)(ADDRESS)ru->next, 1); + Out_Hex((INT64)(ADDRESS)ru->next, 1); Out_Ln(); Out_String((CHAR*)" len: ", 12); Out_Int(ru->len, 1); diff --git a/bootstrap/windows-48/Files.c b/bootstrap/windows-48/Files.c index 3e1b5ecd..2b8c7919 100644 --- a/bootstrap/windows-48/Files.c +++ b/bootstrap/windows-48/Files.c @@ -172,7 +172,7 @@ void Files_DumpFile (Files_File f, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"next: ", 15); - Out_Int((INT32)(ADDRESS)f->next, 1); + Out_Hex((INT32)(ADDRESS)f->next, 1); Out_Ln(); } @@ -196,8 +196,8 @@ void Files_DumpBuffer (Files_Buffer b, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"data: ", 7); - Out_String((CHAR*)"...", 4); Out_Ln(); + Out_HexDump((void*)b->data, 4096); Files_Spaces(indent); Out_String((CHAR*)"f: ", 7); if (b->f == NIL) { diff --git a/bootstrap/windows-48/Out.c b/bootstrap/windows-48/Out.c index 52896b61..f5e37537 100644 --- a/bootstrap/windows-48/Out.c +++ b/bootstrap/windows-48/Out.c @@ -16,6 +16,9 @@ static INT16 Out_in; export void Out_Char (CHAR ch); export void Out_Flush (void); +export void Out_Hex (INT64 x, INT64 n); +export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +export void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l); export void Out_Int (INT64 x, INT64 n); static INT32 Out_Length (CHAR *s, ADDRESS s__len); export void Out_Ln (void); @@ -119,12 +122,86 @@ void Out_Int (INT64 x, INT64 n) } } +void Out_Hex (INT64 x, INT64 n) +{ + if (n < 1) { + n = 1; + } else if (n > 16) { + n = 16; + } + while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) { + n += 1; + } + x = __ROT(x, __ASHL(16 - n, 2), 64); + while (n > 0) { + x = __ROTL(x, 4, 64); + n -= 1; + if (__MASK(x, -16) < 10) { + Out_Char((CHAR)(__MASK(x, -16) + 48)); + } else { + Out_Char((CHAR)((__MASK(x, -16) - 10) + 65)); + } + } +} + void Out_Ln (void) { Out_String(Platform_NL, 3); Out_Flush(); } +void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l) +{ + INT32 i, n, lim; + CHAR c; + lim = a + l; + while (a < lim) { + if (a + 16 < lim) { + n = 16; + } else { + n = lim - a; + } + Out_Hex(o, 8); + Out_Char(' '); + i = 0; + while (i < n) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + __GET(a + i, c, CHAR); + Out_Hex((INT16)c, 2); + Out_Char(' '); + i += 1; + } + while (i < 16) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + Out_String((CHAR*)" ", 4); + i += 1; + } + Out_String((CHAR*)" ", 2); + i = 0; + while (i < n) { + __GET(a + i, c, CHAR); + if ((INT16)c < 32 || (INT16)c > 126) { + Out_Char('.'); + } else { + Out_Char(c); + } + i += 1; + } + a += n; + o += n; + Out_Ln(); + } +} + +void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) +{ + Out_HexDumpAdr((ADDRESS)m, 0, m__len); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; diff --git a/bootstrap/windows-48/Out.h b/bootstrap/windows-48/Out.h index 8c7a5774..bae3e220 100644 --- a/bootstrap/windows-48/Out.h +++ b/bootstrap/windows-48/Out.h @@ -11,6 +11,9 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); import void Out_Flush (void); +import void Out_Hex (INT64 x, INT64 n); +import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +import void Out_HexDumpAdr (INT32 a, INT32 o, INT32 l); import void Out_Int (INT64 x, INT64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, INT16 n); diff --git a/bootstrap/windows-48/Texts.c b/bootstrap/windows-48/Texts.c index 9016dbc8..5450b303 100644 --- a/bootstrap/windows-48/Texts.c +++ b/bootstrap/windows-48/Texts.c @@ -243,13 +243,13 @@ static void Texts_DumpText (Texts_Text t) Out_Int(t->len, 1); Out_Ln(); Out_String((CHAR*)" notify: ", 15); - Out_Int((INT32)(ADDRESS)t->notify, 1); + Out_Hex((INT32)(ADDRESS)t->notify, 1); Out_Ln(); Out_String((CHAR*)" head: ", 15); - Out_Int((INT32)(ADDRESS)t->head, 1); + Out_Hex((INT32)(ADDRESS)t->head, 1); Out_Ln(); Out_String((CHAR*)" cache: ", 15); - Out_Int((INT32)(ADDRESS)t->cache, 1); + Out_Hex((INT32)(ADDRESS)t->cache, 1); Out_Ln(); Out_String((CHAR*)" corg: ", 15); Out_Int(t->corg, 1); @@ -265,7 +265,7 @@ static void Texts_DumpElem (Texts_Elem e) Out_Int(e->H, 1); Out_Ln(); Out_String((CHAR*)" handle: ", 13); - Out_Int((INT32)(ADDRESS)e->handle, 1); + Out_Hex((INT32)(ADDRESS)e->handle, 1); Out_Ln(); Out_String((CHAR*)" base: ", 13); if (e->base == NIL) { @@ -279,11 +279,14 @@ static void Texts_DumpElem (Texts_Elem e) static void Texts_DumpRun (Texts_Run ru) { + Out_String((CHAR*)" Run at ", 10); + Out_Hex((INT32)(ADDRESS)ru, 1); + Out_Ln(); Out_String((CHAR*)" prev: ", 12); - Out_Int((INT32)(ADDRESS)ru->prev, 1); + Out_Hex((INT32)(ADDRESS)ru->prev, 1); Out_Ln(); Out_String((CHAR*)" next: ", 12); - Out_Int((INT32)(ADDRESS)ru->next, 1); + Out_Hex((INT32)(ADDRESS)ru->next, 1); Out_Ln(); Out_String((CHAR*)" len: ", 12); Out_Int(ru->len, 1); diff --git a/bootstrap/windows-88/Files.c b/bootstrap/windows-88/Files.c index 072b15ba..fc649cf8 100644 --- a/bootstrap/windows-88/Files.c +++ b/bootstrap/windows-88/Files.c @@ -173,7 +173,7 @@ void Files_DumpFile (Files_File f, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"next: ", 15); - Out_Int((INT64)(ADDRESS)f->next, 1); + Out_Hex((INT64)(ADDRESS)f->next, 1); Out_Ln(); } @@ -197,8 +197,8 @@ void Files_DumpBuffer (Files_Buffer b, INT16 indent) Out_Ln(); Files_Spaces(indent); Out_String((CHAR*)"data: ", 7); - Out_String((CHAR*)"...", 4); Out_Ln(); + Out_HexDump((void*)b->data, 4096); Files_Spaces(indent); Out_String((CHAR*)"f: ", 7); if (b->f == NIL) { diff --git a/bootstrap/windows-88/Out.c b/bootstrap/windows-88/Out.c index 52896b61..b0d58957 100644 --- a/bootstrap/windows-88/Out.c +++ b/bootstrap/windows-88/Out.c @@ -16,6 +16,9 @@ static INT16 Out_in; export void Out_Char (CHAR ch); export void Out_Flush (void); +export void Out_Hex (INT64 x, INT64 n); +export void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +export void Out_HexDumpAdr (INT64 a, INT64 o, INT64 l); export void Out_Int (INT64 x, INT64 n); static INT32 Out_Length (CHAR *s, ADDRESS s__len); export void Out_Ln (void); @@ -119,12 +122,86 @@ void Out_Int (INT64 x, INT64 n) } } +void Out_Hex (INT64 x, INT64 n) +{ + if (n < 1) { + n = 1; + } else if (n > 16) { + n = 16; + } + while ((n < 16 && __LSH(x, -__ASHL(n, 2), 64) != 0)) { + n += 1; + } + x = __ROT(x, __ASHL(16 - n, 2), 64); + while (n > 0) { + x = __ROTL(x, 4, 64); + n -= 1; + if (__MASK(x, -16) < 10) { + Out_Char((CHAR)(__MASK(x, -16) + 48)); + } else { + Out_Char((CHAR)((__MASK(x, -16) - 10) + 65)); + } + } +} + void Out_Ln (void) { Out_String(Platform_NL, 3); Out_Flush(); } +void Out_HexDumpAdr (INT64 a, INT64 o, INT64 l) +{ + INT64 i, n, lim; + CHAR c; + lim = a + l; + while (a < lim) { + if (a + 16 < lim) { + n = 16; + } else { + n = lim - a; + } + Out_Hex(o, 8); + Out_Char(' '); + i = 0; + while (i < n) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + __GET(a + i, c, CHAR); + Out_Hex((INT16)c, 2); + Out_Char(' '); + i += 1; + } + while (i < 16) { + if (__MASK(i, -4) == 0) { + Out_Char(' '); + } + Out_String((CHAR*)" ", 4); + i += 1; + } + Out_String((CHAR*)" ", 2); + i = 0; + while (i < n) { + __GET(a + i, c, CHAR); + if ((INT16)c < 32 || (INT16)c > 126) { + Out_Char('.'); + } else { + Out_Char(c); + } + i += 1; + } + a += n; + o += n; + Out_Ln(); + } +} + +void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len) +{ + Out_HexDumpAdr((ADDRESS)m, 0, m__len); +} + static void Out_digit (INT64 n, CHAR *s, ADDRESS s__len, INT16 *i) { *i -= 1; diff --git a/bootstrap/windows-88/Out.h b/bootstrap/windows-88/Out.h index 8c7a5774..6962abdc 100644 --- a/bootstrap/windows-88/Out.h +++ b/bootstrap/windows-88/Out.h @@ -11,6 +11,9 @@ import BOOLEAN Out_IsConsole; import void Out_Char (CHAR ch); import void Out_Flush (void); +import void Out_Hex (INT64 x, INT64 n); +import void Out_HexDump (SYSTEM_BYTE *m, ADDRESS m__len); +import void Out_HexDumpAdr (INT64 a, INT64 o, INT64 l); import void Out_Int (INT64 x, INT64 n); import void Out_Ln (void); import void Out_LongReal (LONGREAL x, INT16 n); diff --git a/bootstrap/windows-88/Texts.c b/bootstrap/windows-88/Texts.c index 1afb5eba..c7301f23 100644 --- a/bootstrap/windows-88/Texts.c +++ b/bootstrap/windows-88/Texts.c @@ -243,13 +243,13 @@ static void Texts_DumpText (Texts_Text t) Out_Int(t->len, 1); Out_Ln(); Out_String((CHAR*)" notify: ", 15); - Out_Int((INT64)(ADDRESS)t->notify, 1); + Out_Hex((INT64)(ADDRESS)t->notify, 1); Out_Ln(); Out_String((CHAR*)" head: ", 15); - Out_Int((INT64)(ADDRESS)t->head, 1); + Out_Hex((INT64)(ADDRESS)t->head, 1); Out_Ln(); Out_String((CHAR*)" cache: ", 15); - Out_Int((INT64)(ADDRESS)t->cache, 1); + Out_Hex((INT64)(ADDRESS)t->cache, 1); Out_Ln(); Out_String((CHAR*)" corg: ", 15); Out_Int(t->corg, 1); @@ -265,7 +265,7 @@ static void Texts_DumpElem (Texts_Elem e) Out_Int(e->H, 1); Out_Ln(); Out_String((CHAR*)" handle: ", 13); - Out_Int((INT64)(ADDRESS)e->handle, 1); + Out_Hex((INT64)(ADDRESS)e->handle, 1); Out_Ln(); Out_String((CHAR*)" base: ", 13); if (e->base == NIL) { @@ -279,11 +279,14 @@ static void Texts_DumpElem (Texts_Elem e) static void Texts_DumpRun (Texts_Run ru) { + Out_String((CHAR*)" Run at ", 10); + Out_Hex((INT64)(ADDRESS)ru, 1); + Out_Ln(); Out_String((CHAR*)" prev: ", 12); - Out_Int((INT64)(ADDRESS)ru->prev, 1); + Out_Hex((INT64)(ADDRESS)ru->prev, 1); Out_Ln(); Out_String((CHAR*)" next: ", 12); - Out_Int((INT64)(ADDRESS)ru->next, 1); + Out_Hex((INT64)(ADDRESS)ru->next, 1); Out_Ln(); Out_String((CHAR*)" len: ", 12); Out_Int(ru->len, 1);