Make improvements

This commit is contained in:
Justine Tunney 2020-12-01 03:43:40 -08:00
parent 3e4fd4b0ad
commit e44a0cf6f8
256 changed files with 23100 additions and 2294 deletions

View file

@ -420,6 +420,14 @@ static char *DisRdx(struct Dis *d, uint32_t rde, char *p) {
return DisRegister(p, kGreg[Osz(rde)][Rexw(rde)][0][2]);
}
static char *DisPort(struct Dis *d, uint32_t rde, char *p) {
*p++ = '(';
p = DisRegister(p, kGreg[1][0][0][2]);
*p++ = ')';
*p = '\0';
return p;
}
static char *DisCd(struct Dis *d, uint32_t rde, char *p) {
return DisRegister(p, kCtl[ModrmReg(rde)]);
}
@ -653,6 +661,7 @@ static const struct DisArg {
{"%rAX", DisRax}, //
{"%rDX", DisRdx}, //
{"BBb", DisBBb}, //
{"DX", DisPort}, //
{"EST", DisEst}, //
{"EST1", DisEst1}, //
{"ESsr", DisEssr}, //

View file

@ -18,7 +18,6 @@
02110-1301 USA
*/
#include "libc/log/check.h"
#include "libc/nexgen32e/tinystrcmp.internal.h"
#include "libc/str/str.h"
#include "third_party/zlib/zlib.h"
#include "tool/build/lib/dis.h"
@ -97,30 +96,30 @@ static char *DisName(struct Dis *d, char *bp, const char *name,
rde = d->xedd->op.rde;
if (d->xedd->op.lock) p = stpcpy(p, "lock ");
p = DisRepPrefix(d, p);
if (tinystrcmp(name, "BIT") == 0) {
if (strcmp(name, "BIT") == 0) {
p = stpcpy(p, kBitOp[ModrmReg(rde)]);
} else if (tinystrcmp(name, "nop") == 0 && d->xedd->op.rep) {
} else if (strcmp(name, "nop") == 0 && d->xedd->op.rep) {
p = stpcpy(p, "pause");
} else if (tinystrcmp(name, "CALL") == 0) {
} else if (strcmp(name, "CALL") == 0) {
p = stpcpy(p, "call");
} else if (tinystrcmp(name, "JMP") == 0) {
} else if (strcmp(name, "JMP") == 0) {
p = stpcpy(p, "jmp");
} else if (tinystrcmp(name, "jcxz") == 0) {
} else if (strcmp(name, "jcxz") == 0) {
p = stpcpy(p, kJcxz[Eamode(rde)]);
p = DisBranchTaken(d, p);
} else if (tinystrcmp(name, "loop") == 0 || tinystrcmp(name, "loope") == 0 ||
tinystrcmp(name, "loopne") == 0) {
} else if (strcmp(name, "loop") == 0 || strcmp(name, "loope") == 0 ||
strcmp(name, "loopne") == 0) {
p = stpcpy(p, name);
if (Eamode(rde) != Mode(rde)) {
*p++ = "wl"[Eamode(rde)];
*p = '\0';
}
p = DisBranchTaken(d, p);
} else if (tinystrcmp(name, "cwtl") == 0) {
} else if (strcmp(name, "cwtl") == 0) {
if (Osz(rde)) name = "cbtw";
if (Rexw(rde)) name = "cltq";
p = stpcpy(p, name);
} else if (tinystrcmp(name, "cltd") == 0) {
} else if (strcmp(name, "cltd") == 0) {
if (Osz(rde)) name = "cwtd";
if (Rexw(rde)) name = "cqto";
p = stpcpy(p, name);
@ -132,27 +131,27 @@ static char *DisName(struct Dis *d, char *bp, const char *name,
for (np = name; *np && (islower(*np) || isdigit(*np)); ++np) {
*p++ = *np;
}
if (tinystrcmp(name, "ALU") == 0) {
if (strcmp(name, "ALU") == 0) {
p = stpcpy(p, kAluOp[(d->xedd->op.opcode & 070) >> 3]);
} else if (tinystrcmp(name, "ALU2") == 0) {
} else if (strcmp(name, "ALU2") == 0) {
p = stpcpy(p, kAluOp[ModrmReg(rde)]);
} else if (tinystrcmp(np, "WLQ") == 0) {
} else if (strcmp(np, "WLQ") == 0) {
notbyte = true;
wantsuffix = true;
} else if (tinystrcmp(np, "CC") == 0) {
} else if (strcmp(np, "CC") == 0) {
p = stpcpy(p, kCc[d->xedd->op.opcode & 15]);
p = DisBranchTaken(d, p);
} else if (tinystrcmp(np, "WQ") == 0) {
} else if (strcmp(np, "WQ") == 0) {
notbyte = true;
notlong = Eamode(rde) != XED_MODE_REAL;
wantsuffix = true;
} else if (tinystrcmp(np, "LQ") == 0 || tinystrcmp(np, "WL") == 0) {
} else if (strcmp(np, "LQ") == 0 || strcmp(np, "WL") == 0) {
notbyte = true;
wantsuffix = true;
} else if (tinystrcmp(np, "SD") == 0) {
} else if (strcmp(np, "SD") == 0) {
notbyte = true;
wantsuffixsd = true;
} else if (tinystrcmp(np, "ABS") == 0) {
} else if (strcmp(np, "ABS") == 0) {
if (Rexw(rde)) p = stpcpy(p, "abs");
}
if (wantsuffixsd) {

View file

@ -177,10 +177,10 @@ const char *DisSpecMap0(struct XedDecodedInst *x, char *p) {
RCASE(0x69, "imul %Gvqp Evqp Ivds");
RCASE(0x6A, "pushWQ Ibss");
RCASE(0x6B, "imul %Gvqp Evqp Ibs");
RCASE(0x6C, "insb Yb %dx");
RCASE(0x6D, "insWL Yv %dx");
RCASE(0x6E, "outsb %dx Xb");
RCASE(0x6F, "outsWL %dx Xv");
RCASE(0x6C, "insb Yb DX");
RCASE(0x6D, "insWL Yv DX");
RCASE(0x6E, "outsb DX Xb");
RCASE(0x6F, "outsWL DX Xv");
RCASE(0x70 ... 0x7f, "jCC Jbs");
RCASE(0x80, "ALU2 Eb Ib");
RCASE(0x81, "ALU2 Evqp Ivds");
@ -258,10 +258,10 @@ const char *DisSpecMap0(struct XedDecodedInst *x, char *p) {
RCASE(0xE9, "jmp Jvds");
RCASE(0xEA, "ljmp Rvds Kvds");
RCASE(0xEB, "jmp Jbs");
RCASE(0xEC, "in %al %dx");
RCASE(0xED, "in %eAX %dx");
RCASE(0xEE, "out %dx %al");
RCASE(0xEF, "out %dx %eAX");
RCASE(0xEC, "in %al DX");
RCASE(0xED, "in %eAX DX");
RCASE(0xEE, "out DX %al");
RCASE(0xEF, "out DX %eAX");
RCASE(0xF1, "int1");
RCASE(0xF4, "hlt");
RCASE(0xF5, "cmc");

View file

@ -21,7 +21,7 @@
#include "libc/alg/arraylist2.internal.h"
#include "libc/bits/safemacros.internal.h"
#include "libc/mem/mem.h"
#include "libc/str/knuthmultiplicativehash.h"
#include "libc/str/knuthmultiplicativehash.internal.h"
#include "libc/str/str.h"
#include "libc/x/x.h"
#include "tool/build/lib/interner.h"