improve formatting of disassembly output (#21123)

This commit is contained in:
Walter Bright 2025-03-30 21:18:18 -07:00 committed by GitHub
parent 6656cd920c
commit c78c240d37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2284,35 +2284,48 @@ void disassemble(uint c) @trusted
//printf("%x\n", field(ins, 31, 25)); //printf("%x\n", field(ins, 31, 25));
//printf("p1: %s\n", p1); //printf("p1: %s\n", p1);
auto plen = 1 + p1.length;
put(' '); put(' ');
puts(p1); puts(p1);
if (p2.length > 0) if (p2.length > 0)
{ {
foreach (len1; p1.length .. 9) foreach (len1; p1.length .. 9)
{
++plen;
put(' '); put(' ');
}
plen += 1 + s2.length;
put(' '); put(' ');
puts(s2); puts(s2);
if (p2[0] != ' ') if (p2[0] != ' ')
{
plen += p2.length;
puts(p2); puts(p2);
}
if (p3.length > 0) if (p3.length > 0)
{ {
plen += sep.length + s3.length + p3.length;
puts(sep); puts(sep);
puts(s3); puts(s3);
puts(p3); puts(p3);
if (p4.length > 0) if (p4.length > 0)
{ {
plen += 1 + p4.length;
put(','); put(',');
puts(p4); puts(p4);
if (p5.length > 0) if (p5.length > 0)
{ {
plen += 1 + p5.length;
put(','); put(',');
puts(p5); puts(p5);
if (p6.length > 0) if (p6.length > 0)
{ {
plen += 1 + p6.length;
put(','); put(',');
puts(p6); puts(p6);
if (p7.length > 0) if (p7.length > 0)
{ {
plen += 1 + p7.length;
put(','); put(',');
puts(p7); puts(p7);
} }
@ -2324,7 +2337,9 @@ void disassemble(uint c) @trusted
if (bURL && url) if (bURL && url)
{ {
puts(" // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#"); for (; plen < 29; ++plen)
put(' ');
puts(" // https://www.scs.stanford.edu/~zyedidia/arm64/encodingindex.html#");
puts(url); puts(url);
} }
} }
@ -2473,7 +2488,7 @@ const(char)[] signedWordtostring(int w)
{ {
__gshared char[1 + 3 + 1 + w.sizeof * 3 + 1 + 1] EA; __gshared char[1 + 3 + 1 + w.sizeof * 3 + 1 + 1] EA;
const n = snprintf(EA.ptr, EA.length, ((w <= 16 && w >= -32) ? "#%d" : "#0x%X"), w); const n = snprintf(EA.ptr, EA.length, ((w <= 16) ? "#%d" : "#0x%X"), w);
return EA[0 .. n]; return EA[0 .. n];
} }