Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
disasm.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/kassert.h>
#include <sys/kdebug.h>
Include dependency graph for disasm.c:

Go to the source code of this file.

Data Structures

struct  inst
 
struct  finst
 
struct  i_addr
 

Macros

#define DB_STGY_ANY   0
 
#define DB_STGY_XTRN   1
 
#define DB_STGY_PROC   2
 
#define TRUE   1
 
#define FALSE   0
 
#define BYTE   0
 
#define WORD   1
 
#define LONG   2
 
#define QUAD   3
 
#define SNGL   4
 
#define DBLR   5
 
#define EXTR   6
 
#define SDEP   7
 
#define ADEP   8
 
#define ESC   9
 
#define NONE   10
 
#define REX_B   1
 
#define REX_X   2
 
#define REX_R   4
 
#define REX_W   8
 
#define REX   0x40
 
#define E   1 /* general effective address */
 
#define Eind   2 /* indirect address (jump, call) */
 
#define Ew   3 /* address, word size */
 
#define Eb   4 /* address, byte size */
 
#define R   5 /* register, in 'reg' field */
 
#define Rw   6 /* word register, in 'reg' field */
 
#define Rq   39 /* quad register, in 'reg' field */
 
#define Ri   7 /* register in instruction */
 
#define S   8 /* segment reg, in 'reg' field */
 
#define Si   9 /* segment reg, in instruction */
 
#define A   10 /* accumulator */
 
#define BX   11 /* (bx) */
 
#define CL   12 /* cl, for shifts */
 
#define DX   13 /* dx, for IO */
 
#define SI   14 /* si */
 
#define DI   15 /* di */
 
#define CR   16 /* control register */
 
#define DR   17 /* debug register */
 
#define TR   18 /* test register */
 
#define I   19 /* immediate, unsigned */
 
#define Is   20 /* immediate, signed */
 
#define Ib   21 /* byte immediate, unsigned */
 
#define Ibs   22 /* byte immediate, signed */
 
#define Iw   23 /* word immediate, unsigned */
 
#define Ilq   24 /* long/quad immediate, unsigned */
 
#define O   25 /* direct address */
 
#define Db   26 /* byte displacement from EIP */
 
#define Dl   27 /* long displacement from EIP */
 
#define o1   28 /* constant 1 */
 
#define o3   29 /* constant 3 */
 
#define OS   30 /* immediate offset/segment */
 
#define ST   31 /* FP stack top */
 
#define STI   32 /* FP stack */
 
#define X   33 /* extended FP op */
 
#define XA   34 /* for 'fstcw %ax' */
 
#define El   35 /* address, long/quad size */
 
#define Ril   36 /* long register in instruction */
 
#define Iba   37 /* byte immediate, don't print if 0xa */
 
#define EL   38 /* address, explicitly long size */
 
#define op1(x)   (x)
 
#define op2(x, y)   ((x)|((y)<<8))
 
#define op3(x, y, z)   ((x)|((y)<<8)|((z)<<16))
 
#define f_mod(rex, byte)   ((byte)>>6)
 
#define f_reg(rex, byte)   ((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))
 
#define f_rm(rex, byte)   (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
 
#define sib_ss(rex, byte)   ((byte)>>6)
 
#define sib_index(rex, byte)   ((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))
 
#define sib_base(rex, byte)   (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))
 
#define get_value_inc(result, loc, size, is_signed)
 

Functions

static uintptr_t db_disasm_esc (uintptr_t loc, int inst, int rex, int short_addr, int size, const char *seg)
 
static void db_print_address (const char *seg, int size, int rex, struct i_addr *addrp)
 
static uintptr_t db_read_address (uintptr_t loc, int short_addr, int rex, int regmodrm, struct i_addr *addrp)
 
uintptr_t db_disasm (uintptr_t loc, bool altfmt)
 

Variables

static const struct inst db_inst_0f388x []
 
static const struct inst *const db_inst_0f38 []
 
static const char *const db_Grp6 []
 
static const char *const db_Grp7 []
 
static const char *const db_Grp8 []
 
static const char *const db_Grp9 []
 
static const char *const db_Grp15 []
 
static const char *const db_Grp15b []
 
static const struct inst db_inst_0f0x []
 
static const struct inst db_inst_0f2x []
 
static const struct inst db_inst_0f3x []
 
static const struct inst db_inst_0f4x []
 
static const struct inst db_inst_0f7x []
 
static const struct inst db_inst_0f8x []
 
static const struct inst db_inst_0f9x []
 
static const struct inst db_inst_0fax []
 
static const struct inst db_inst_0fbx []
 
static const struct inst db_inst_0fcx []
 
static const struct inst *const db_inst_0f []
 
static const char *const db_Esc92 []
 
static const char *const db_Esc94 []
 
static const char *const db_Esc95 []
 
static const char *const db_Esc96 []
 
static const char *const db_Esc97 []
 
static const char *const db_Esca5 []
 
static const char *const db_Escb4 []
 
static const char *const db_Esce3 []
 
static const char *const db_Escf4 []
 
static const struct finst db_Esc8 []
 
static const struct finst db_Esc9 []
 
static const struct finst db_Esca []
 
static const struct finst db_Escb []
 
static const struct finst db_Escc []
 
static const struct finst db_Escd []
 
static const struct finst db_Esce []
 
static const struct finst db_Escf []
 
static const struct finst *const db_Esc_inst []
 
static const char *const db_Grp1 []
 
static const char *const db_Grp2 []
 
static const struct inst db_Grp3 []
 
static const struct inst db_Grp4 []
 
static const struct inst db_Grp5 []
 
static const struct inst db_inst_table [256]
 
static const struct inst db_bad_inst
 
static const char *const db_reg [2][4][16]
 
static const char *const db_seg_reg [8]
 
static const int db_lengths []
 

Data Structure Documentation

◆ inst

struct inst

Definition at line 114 of file disasm.c.

Collaboration diagram for inst:
[legend]
Data Fields
const void * i_extra
short i_has_modrm
int i_mode
const char * i_name
short i_size

◆ finst

struct finst

Definition at line 126 of file disasm.c.

Collaboration diagram for finst:
[legend]
Data Fields
const char * f_name
int f_rrmode
const void * f_rrname
int f_size

◆ i_addr

struct i_addr

Definition at line 941 of file disasm.c.

Collaboration diagram for i_addr:
[legend]
Data Fields
const char * base
int disp
const char * index
int is_reg
int ss

Macro Definition Documentation

◆ A

#define A   10 /* accumulator */

Definition at line 84 of file disasm.c.

◆ ADEP

#define ADEP   8

Definition at line 58 of file disasm.c.

◆ BX

#define BX   11 /* (bx) */

Definition at line 85 of file disasm.c.

◆ BYTE

#define BYTE   0

Definition at line 50 of file disasm.c.

◆ CL

#define CL   12 /* cl, for shifts */

Definition at line 86 of file disasm.c.

◆ CR

#define CR   16 /* control register */

Definition at line 90 of file disasm.c.

◆ Db

#define Db   26 /* byte displacement from EIP */

Definition at line 100 of file disasm.c.

◆ DB_STGY_ANY

#define DB_STGY_ANY   0

Definition at line 41 of file disasm.c.

◆ DB_STGY_PROC

#define DB_STGY_PROC   2

Definition at line 43 of file disasm.c.

◆ DB_STGY_XTRN

#define DB_STGY_XTRN   1

Definition at line 42 of file disasm.c.

◆ DBLR

#define DBLR   5

Definition at line 55 of file disasm.c.

◆ DI

#define DI   15 /* di */

Definition at line 89 of file disasm.c.

◆ Dl

#define Dl   27 /* long displacement from EIP */

Definition at line 101 of file disasm.c.

◆ DR

#define DR   17 /* debug register */

Definition at line 91 of file disasm.c.

◆ DX

#define DX   13 /* dx, for IO */

Definition at line 87 of file disasm.c.

◆ E

#define E   1 /* general effective address */

Definition at line 74 of file disasm.c.

◆ Eb

#define Eb   4 /* address, byte size */

Definition at line 77 of file disasm.c.

◆ Eind

#define Eind   2 /* indirect address (jump, call) */

Definition at line 75 of file disasm.c.

◆ El

#define El   35 /* address, long/quad size */

Definition at line 109 of file disasm.c.

◆ EL

#define EL   38 /* address, explicitly long size */

Definition at line 112 of file disasm.c.

◆ ESC

#define ESC   9

Definition at line 59 of file disasm.c.

◆ Ew

#define Ew   3 /* address, word size */

Definition at line 76 of file disasm.c.

◆ EXTR

#define EXTR   6

Definition at line 56 of file disasm.c.

◆ f_mod

#define f_mod (   rex,
  byte 
)    ((byte)>>6)

Definition at line 933 of file disasm.c.

◆ f_reg

#define f_reg (   rex,
  byte 
)    ((((byte)>>3)&0x7) | (rex & REX_R ? 0x8 : 0x0))

Definition at line 934 of file disasm.c.

◆ f_rm

#define f_rm (   rex,
  byte 
)    (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))

Definition at line 935 of file disasm.c.

◆ FALSE

#define FALSE   0

Definition at line 45 of file disasm.c.

◆ get_value_inc

#define get_value_inc (   result,
  loc,
  size,
  is_signed 
)
Value:
result = Debug_GetValue((loc), (size), (is_signed)); \
(loc) += (size);
uint64_t Debug_GetValue(uintptr_t addr, int size, bool isSigned)
Definition: debug.c:81
uint32_t size
Definition: multiboot.h:0

Definition at line 987 of file disasm.c.

◆ I

#define I   19 /* immediate, unsigned */

Definition at line 93 of file disasm.c.

◆ Ib

#define Ib   21 /* byte immediate, unsigned */

Definition at line 95 of file disasm.c.

◆ Iba

#define Iba   37 /* byte immediate, don't print if 0xa */

Definition at line 111 of file disasm.c.

◆ Ibs

#define Ibs   22 /* byte immediate, signed */

Definition at line 96 of file disasm.c.

◆ Ilq

#define Ilq   24 /* long/quad immediate, unsigned */

Definition at line 98 of file disasm.c.

◆ Is

#define Is   20 /* immediate, signed */

Definition at line 94 of file disasm.c.

◆ Iw

#define Iw   23 /* word immediate, unsigned */

Definition at line 97 of file disasm.c.

◆ LONG

#define LONG   2

Definition at line 52 of file disasm.c.

◆ NONE

#define NONE   10

Definition at line 60 of file disasm.c.

◆ O

#define O   25 /* direct address */

Definition at line 99 of file disasm.c.

◆ o1

#define o1   28 /* constant 1 */

Definition at line 102 of file disasm.c.

◆ o3

#define o3   29 /* constant 3 */

Definition at line 103 of file disasm.c.

◆ op1

#define op1 (   x)    (x)

Definition at line 122 of file disasm.c.

◆ op2

#define op2 (   x,
 
)    ((x)|((y)<<8))

Definition at line 123 of file disasm.c.

◆ op3

#define op3 (   x,
  y,
 
)    ((x)|((y)<<8)|((z)<<16))

Definition at line 124 of file disasm.c.

◆ OS

#define OS   30 /* immediate offset/segment */

Definition at line 104 of file disasm.c.

◆ QUAD

#define QUAD   3

Definition at line 53 of file disasm.c.

◆ R

#define R   5 /* register, in 'reg' field */

Definition at line 78 of file disasm.c.

◆ REX

#define REX   0x40

Definition at line 69 of file disasm.c.

◆ REX_B

#define REX_B   1

Definition at line 65 of file disasm.c.

◆ REX_R

#define REX_R   4

Definition at line 67 of file disasm.c.

◆ REX_W

#define REX_W   8

Definition at line 68 of file disasm.c.

◆ REX_X

#define REX_X   2

Definition at line 66 of file disasm.c.

◆ Ri

#define Ri   7 /* register in instruction */

Definition at line 81 of file disasm.c.

◆ Ril

#define Ril   36 /* long register in instruction */

Definition at line 110 of file disasm.c.

◆ Rq

#define Rq   39 /* quad register, in 'reg' field */

Definition at line 80 of file disasm.c.

◆ Rw

#define Rw   6 /* word register, in 'reg' field */

Definition at line 79 of file disasm.c.

◆ S

#define S   8 /* segment reg, in 'reg' field */

Definition at line 82 of file disasm.c.

◆ SDEP

#define SDEP   7

Definition at line 57 of file disasm.c.

◆ Si

#define Si   9 /* segment reg, in instruction */

Definition at line 83 of file disasm.c.

◆ SI

#define SI   14 /* si */

Definition at line 88 of file disasm.c.

◆ sib_base

#define sib_base (   rex,
  byte 
)    (((byte)&0x7) | (rex & REX_B ? 0x8 : 0x0))

Definition at line 939 of file disasm.c.

◆ sib_index

#define sib_index (   rex,
  byte 
)    ((((byte)>>3)&0x7) | (rex & REX_X ? 0x8 : 0x0))

Definition at line 938 of file disasm.c.

◆ sib_ss

#define sib_ss (   rex,
  byte 
)    ((byte)>>6)

Definition at line 937 of file disasm.c.

◆ SNGL

#define SNGL   4

Definition at line 54 of file disasm.c.

◆ ST

#define ST   31 /* FP stack top */

Definition at line 105 of file disasm.c.

◆ STI

#define STI   32 /* FP stack */

Definition at line 106 of file disasm.c.

◆ TR

#define TR   18 /* test register */

Definition at line 92 of file disasm.c.

◆ TRUE

#define TRUE   1

Definition at line 44 of file disasm.c.

◆ WORD

#define WORD   1

Definition at line 51 of file disasm.c.

◆ X

#define X   33 /* extended FP op */

Definition at line 107 of file disasm.c.

◆ XA

#define XA   34 /* for 'fstcw %ax' */

Definition at line 108 of file disasm.c.

Function Documentation

◆ db_disasm()

uintptr_t db_disasm ( uintptr_t  loc,
bool  altfmt 
)

Definition at line 1186 of file disasm.c.

1187{
1188 int inst;
1189 int size;
1190 int short_addr;
1191 const char * seg;
1192 const struct inst * ip;
1193 const char * i_name;
1194 int i_size;
1195 int i_mode;
1196 int rex = 0;
1197 int regmodrm = 0;
1198 bool first;
1199 int displ;
1200 int prefix;
1201 int rep;
1202 int imm;
1203 int imm2;
1204 long imm64;
1205 int len;
1206 struct i_addr address;
1207
1208 get_value_inc(inst, loc, 1, FALSE);
1209 short_addr = FALSE;
1210 size = LONG;
1211 seg = 0;
1212
1213 /*
1214 * Get prefixes
1215 */
1216 rep = FALSE;
1217 prefix = TRUE;
1218 do {
1219 switch (inst) {
1220 case 0x66: /* data16 */
1221 size = WORD;
1222 break;
1223 case 0x67:
1224 short_addr = TRUE;
1225 break;
1226 case 0x26:
1227 seg = "%es";
1228 break;
1229 case 0x36:
1230 seg = "%ss";
1231 break;
1232 case 0x2e:
1233 seg = "%cs";
1234 break;
1235 case 0x3e:
1236 seg = "%ds";
1237 break;
1238 case 0x64:
1239 seg = "%fs";
1240 break;
1241 case 0x65:
1242 seg = "%gs";
1243 break;
1244 case 0xf0:
1245 kprintf("lock ");
1246 break;
1247 case 0xf2:
1248 kprintf("repne ");
1249 break;
1250 case 0xf3:
1251 rep = TRUE;
1252 break;
1253 default:
1254 prefix = FALSE;
1255 break;
1256 }
1257 if (inst >= 0x40 && inst < 0x50) {
1258 rex = inst;
1259 prefix = TRUE;
1260 }
1261 if (prefix) {
1262 get_value_inc(inst, loc, 1, FALSE);
1263 }
1264 } while (prefix);
1265
1266 if (inst >= 0xd8 && inst <= 0xdf) {
1267 loc = db_disasm_esc(loc, inst, rex, short_addr, size, seg);
1268 kprintf("\n");
1269 return (loc);
1270 }
1271
1272 ip = &db_inst_table[inst];
1273 while (ip->i_size == ESC) {
1274 get_value_inc(inst, loc, 1, FALSE);
1275 ip = ((const struct inst * const *)ip->i_extra)[inst>>4];
1276 if (ip == 0) {
1277 ip = &db_bad_inst;
1278 }
1279 else {
1280 ip = &ip[inst&0xf];
1281 }
1282 }
1283
1284 if (ip->i_has_modrm) {
1285 get_value_inc(regmodrm, loc, 1, FALSE);
1286 loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
1287 }
1288
1289 i_name = ip->i_name;
1290 i_size = ip->i_size;
1291 i_mode = ip->i_mode;
1292
1293 if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
1294 ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
1295 ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 ||
1296 ip->i_extra == db_Grp15) {
1297 i_name = ((const char * const *)ip->i_extra)[f_reg(rex, regmodrm)];
1298 }
1299 else if (ip->i_extra == db_Grp3) {
1300 ip = ip->i_extra;
1301 ip = &ip[f_reg(rex, regmodrm)];
1302 i_name = ip->i_name;
1303 i_mode = ip->i_mode;
1304 }
1305 else if (ip->i_extra == db_Grp4 || ip->i_extra == db_Grp5) {
1306 ip = ip->i_extra;
1307 ip = &ip[f_reg(rex, regmodrm)];
1308 i_name = ip->i_name;
1309 i_mode = ip->i_mode;
1310 i_size = ip->i_size;
1311 }
1312
1313 /* Special cases that don't fit well in the tables. */
1314 if (ip->i_extra == db_Grp7 && f_mod(rex, regmodrm) == 3) {
1315 switch (regmodrm) {
1316 case 0xc1:
1317 i_name = "vmcall";
1318 i_size = NONE;
1319 i_mode = 0;
1320 break;
1321 case 0xc2:
1322 i_name = "vmlaunch";
1323 i_size = NONE;
1324 i_mode = 0;
1325 break;
1326 case 0xc3:
1327 i_name = "vmresume";
1328 i_size = NONE;
1329 i_mode = 0;
1330 break;
1331 case 0xc4:
1332 i_name = "vmxoff";
1333 i_size = NONE;
1334 i_mode = 0;
1335 break;
1336 case 0xc8:
1337 i_name = "monitor";
1338 i_size = NONE;
1339 i_mode = 0;
1340 break;
1341 case 0xc9:
1342 i_name = "mwait";
1343 i_size = NONE;
1344 i_mode = 0;
1345 break;
1346 case 0xd0:
1347 i_name = "xgetbv";
1348 i_size = NONE;
1349 i_mode = 0;
1350 break;
1351 case 0xd1:
1352 i_name = "xsetbv";
1353 i_size = NONE;
1354 i_mode = 0;
1355 break;
1356 case 0xf8:
1357 i_name = "swapgs";
1358 i_size = NONE;
1359 i_mode = 0;
1360 break;
1361 case 0xf9:
1362 i_name = "rdtscp";
1363 i_size = NONE;
1364 i_mode = 0;
1365 break;
1366 }
1367 }
1368 if (ip->i_extra == db_Grp15 && f_mod(rex, regmodrm) == 3) {
1369 i_name = db_Grp15b[f_reg(rex, regmodrm)];
1370 i_size = NONE;
1371 i_mode = 0;
1372 }
1373
1374 /* Handle instructions identified by mandatory prefixes. */
1375 if (rep == TRUE) {
1376 if (inst == 0x90) {
1377 i_name = "pause";
1378 i_size = NONE;
1379 i_mode = 0;
1380 rep = FALSE;
1381 } else if (ip->i_extra == db_Grp9 && f_mod(rex, regmodrm) != 3 &&
1382 f_reg(rex, regmodrm) == 0x6) {
1383 i_name = "vmxon";
1384 rep = FALSE;
1385 }
1386 }
1387 if (size == WORD) {
1388 if (ip->i_extra == db_Grp9 && f_mod(rex, regmodrm) != 3 &&
1389 f_reg(rex, regmodrm) == 0x6) {
1390 i_name = "vmclear";
1391 }
1392 }
1393 if (rex & REX_W) {
1394 if (strcmp(i_name, "cwde") == 0)
1395 i_name = "cdqe";
1396 else if (strcmp(i_name, "cmpxchg8b") == 0)
1397 i_name = "cmpxchg16b";
1398 }
1399
1400 if (rep == TRUE)
1401 kprintf("repe "); /* XXX repe VS rep */
1402
1403 if (i_size == SDEP) {
1404 if (size == LONG)
1405 kprintf("%s", i_name);
1406 else
1407 kprintf("%s", (const char *)ip->i_extra);
1408 } else if (i_size == ADEP) {
1409 if (short_addr == FALSE)
1410 kprintf("%s", i_name);
1411 else
1412 kprintf("%s", (const char *)ip->i_extra);
1413 }
1414 else {
1415 kprintf("%s", i_name);
1416 if ((inst >= 0x50 && inst <= 0x5f) || inst == 0x68 || inst == 0x6a) {
1417 i_size = NONE;
1418 kprintf("q");
1419 }
1420 if (i_size != NONE) {
1421 if (i_size == BYTE) {
1422 kprintf("b");
1423 size = BYTE;
1424 }
1425 else if (i_size == WORD) {
1426 kprintf("w");
1427 size = WORD;
1428 }
1429 else if (size == WORD)
1430 kprintf("w");
1431 else {
1432 if (rex & REX_W)
1433 kprintf("q");
1434 else
1435 kprintf("l");
1436 }
1437 }
1438 }
1439 kprintf("\t");
1440 for (first = TRUE;
1441 i_mode != 0;
1442 i_mode >>= 8, first = FALSE)
1443 {
1444 if (!first)
1445 kprintf(",");
1446
1447 switch (i_mode & 0xFF) {
1448
1449 case E:
1450 db_print_address(seg, size, rex, &address);
1451 break;
1452
1453 case Eind:
1454 kprintf("*");
1455 db_print_address(seg, size, rex, &address);
1456 break;
1457
1458 case El:
1459 db_print_address(seg, (rex & REX_W) ? QUAD : LONG, rex, &address);
1460 break;
1461
1462 case EL:
1463 db_print_address(seg, LONG, 0, &address);
1464 break;
1465
1466 case Ew:
1467 db_print_address(seg, WORD, rex, &address);
1468 break;
1469
1470 case Eb:
1471 db_print_address(seg, BYTE, rex, &address);
1472 break;
1473
1474 case R:
1475 kprintf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][f_reg(rex, regmodrm)]);
1476 break;
1477
1478 case Rw:
1479 kprintf("%s", db_reg[rex != 0 ? 1 : 0][WORD][f_reg(rex, regmodrm)]);
1480 break;
1481
1482 case Rq:
1483 kprintf("%s", db_reg[rex != 0 ? 1 : 0][QUAD][f_reg(rex, regmodrm)]);
1484 break;
1485
1486 case Ri:
1487 kprintf("%s", db_reg[0][QUAD][f_rm(rex, inst)]);
1488 break;
1489
1490 case Ril:
1491 kprintf("%s", db_reg[rex != 0 ? 1 : 0][(rex & REX_R) ? QUAD : LONG][f_rm(rex, inst)]);
1492 break;
1493
1494 case S:
1495 kprintf("%s", db_seg_reg[f_reg(rex, regmodrm)]);
1496 break;
1497
1498 case Si:
1499 kprintf("%s", db_seg_reg[f_reg(rex, inst)]);
1500 break;
1501
1502 case A:
1503 kprintf("%s", db_reg[rex != 0 ? 1 : 0][size][0]); /* acc */
1504 break;
1505
1506 case BX:
1507 if (seg)
1508 kprintf("%s:", seg);
1509 kprintf("(%s)", short_addr ? "%bx" : "%ebx");
1510 break;
1511
1512 case CL:
1513 kprintf("%%cl");
1514 break;
1515
1516 case DX:
1517 kprintf("%%dx");
1518 break;
1519
1520 case SI:
1521 if (seg)
1522 kprintf("%s:", seg);
1523 kprintf("(%s)", short_addr ? "%si" : "%rsi");
1524 break;
1525
1526 case DI:
1527 kprintf("%%es:(%s)", short_addr ? "%di" : "%rdi");
1528 break;
1529
1530 case CR:
1531 kprintf("%%cr%d", f_reg(rex, regmodrm));
1532 break;
1533
1534 case DR:
1535 kprintf("%%dr%d", f_reg(rex, regmodrm));
1536 break;
1537
1538 case TR:
1539 kprintf("%%tr%d", f_reg(rex, regmodrm));
1540 break;
1541
1542 case I:
1543 len = db_lengths[size];
1544 get_value_inc(imm, loc, len, FALSE);
1545 kprintf("$%d", imm);
1546 break;
1547
1548 case Is:
1549 len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
1550 get_value_inc(imm, loc, len, FALSE);
1551 kprintf("$%d", imm);
1552 break;
1553
1554 case Ib:
1555 get_value_inc(imm, loc, 1, FALSE);
1556 kprintf("$%d", imm);
1557 break;
1558
1559 case Iba:
1560 get_value_inc(imm, loc, 1, FALSE);
1561 if (imm != 0x0a)
1562 kprintf("$%d", imm);
1563 break;
1564
1565 case Ibs:
1566 get_value_inc(imm, loc, 1, TRUE);
1567 if (size == WORD)
1568 imm &= 0xFFFF;
1569 kprintf("$%d", imm);
1570 break;
1571
1572 case Iw:
1573 get_value_inc(imm, loc, 2, FALSE);
1574 kprintf("$%d", imm);
1575 break;
1576
1577 case Ilq:
1578 len = db_lengths[rex & REX_W ? QUAD : LONG];
1579 get_value_inc(imm64, loc, len, FALSE);
1580 kprintf("$%#lr", imm64);
1581 break;
1582
1583 case O:
1584 len = (short_addr ? 2 : 4);
1585 get_value_inc(displ, loc, len, FALSE);
1586 if (seg)
1587 kprintf("%s:%d",seg, displ);
1588 else
1590 break;
1591
1592 case Db:
1593 get_value_inc(displ, loc, 1, TRUE);
1594 displ += loc;
1595 if (size == WORD)
1596 displ &= 0xFFFF;
1598 break;
1599
1600 case Dl:
1601 len = db_lengths[(size == LONG && (rex & REX_W)) ? QUAD : size];
1602 get_value_inc(displ, loc, len, FALSE);
1603 displ += loc;
1604 if (size == WORD)
1605 displ &= 0xFFFF;
1607 break;
1608
1609 case o1:
1610 kprintf("$1");
1611 break;
1612
1613 case o3:
1614 kprintf("$3");
1615 break;
1616
1617 case OS:
1618 len = db_lengths[size];
1619 get_value_inc(imm, loc, len, FALSE); /* offset */
1620 get_value_inc(imm2, loc, 2, FALSE); /* segment */
1621 kprintf("$%d,%d", imm2, imm);
1622 break;
1623 }
1624 }
1625 kprintf("\n");
1626 return (loc);
1627}
#define E
Definition: disasm.c:74
#define Iw
Definition: disasm.c:97
#define BX
Definition: disasm.c:85
#define ADEP
Definition: disasm.c:58
#define Ib
Definition: disasm.c:95
static const char *const db_Grp1[]
Definition: disasm.c:583
#define REX_R
Definition: disasm.c:67
#define Is
Definition: disasm.c:94
static const char *const db_reg[2][4][16]
Definition: disasm.c:949
#define OS
Definition: disasm.c:104
#define DR
Definition: disasm.c:91
#define O
Definition: disasm.c:99
#define DX
Definition: disasm.c:87
int i_mode
Definition: disasm.c:118
static const struct inst db_Grp4[]
Definition: disasm.c:616
static void db_print_address(const char *seg, int size, int rex, struct i_addr *addrp)
Definition: disasm.c:1067
static uintptr_t db_disasm_esc(uintptr_t loc, int inst, int rex, int short_addr, int size, const char *seg)
Definition: disasm.c:1095
static const char *const db_Grp15[]
Definition: disasm.c:217
#define ESC
Definition: disasm.c:59
#define WORD
Definition: disasm.c:51
#define TR
Definition: disasm.c:92
#define Db
Definition: disasm.c:100
static const struct inst db_inst_table[256]
Definition: disasm.c:638
short i_size
Definition: disasm.c:117
static const char *const db_Grp7[]
Definition: disasm.c:184
#define Ibs
Definition: disasm.c:96
#define R
Definition: disasm.c:78
static const struct inst db_Grp5[]
Definition: disasm.c:627
static const char *const db_Grp15b[]
Definition: disasm.c:228
#define I
Definition: disasm.c:93
#define NONE
Definition: disasm.c:60
static const char *const db_Grp2[]
Definition: disasm.c:594
#define SDEP
Definition: disasm.c:57
#define f_rm(rex, byte)
Definition: disasm.c:935
#define Eb
Definition: disasm.c:77
#define DB_STGY_ANY
Definition: disasm.c:41
#define Ew
Definition: disasm.c:76
#define El
Definition: disasm.c:109
#define Ilq
Definition: disasm.c:98
#define EL
Definition: disasm.c:112
#define REX_W
Definition: disasm.c:68
#define Dl
Definition: disasm.c:101
static const char *const db_Grp8[]
Definition: disasm.c:195
const void * i_extra
Definition: disasm.c:119
#define Si
Definition: disasm.c:83
#define Eind
Definition: disasm.c:75
#define CR
Definition: disasm.c:90
#define Ri
Definition: disasm.c:81
#define CL
Definition: disasm.c:86
#define DB_STGY_XTRN
Definition: disasm.c:42
short i_has_modrm
Definition: disasm.c:116
#define A
Definition: disasm.c:84
#define Rw
Definition: disasm.c:79
#define Ril
Definition: disasm.c:110
#define f_reg(rex, byte)
Definition: disasm.c:934
#define SI
Definition: disasm.c:88
#define f_mod(rex, byte)
Definition: disasm.c:933
#define get_value_inc(result, loc, size, is_signed)
Definition: disasm.c:987
#define o3
Definition: disasm.c:103
#define TRUE
Definition: disasm.c:44
#define FALSE
Definition: disasm.c:45
static uintptr_t db_read_address(uintptr_t loc, int short_addr, int rex, int regmodrm, struct i_addr *addrp)
Definition: disasm.c:1004
static const int db_lengths[]
Definition: disasm.c:977
#define QUAD
Definition: disasm.c:53
const char * i_name
Definition: disasm.c:115
#define LONG
Definition: disasm.c:52
#define DI
Definition: disasm.c:89
#define Rq
Definition: disasm.c:80
static const char *const db_seg_reg[8]
Definition: disasm.c:970
static const struct inst db_Grp3[]
Definition: disasm.c:605
static const char *const db_Grp6[]
Definition: disasm.c:173
#define o1
Definition: disasm.c:102
static const char *const db_Grp9[]
Definition: disasm.c:206
#define BYTE
Definition: disasm.c:50
#define Iba
Definition: disasm.c:111
static const struct inst db_bad_inst
Definition: disasm.c:929
#define S
Definition: disasm.c:82
Definition: disasm.c:941
Definition: disasm.c:114
int kprintf(const char *fmt,...)
Definition: printf.c:210
void Debug_PrintSymbol(uintptr_t off, int strategy)
Definition: debug.c:118
uint64_t len
Definition: multiboot.h:2
int strcmp(const char *s1, const char *s2)
Definition: string.c:81
uint64_t uintptr_t
Definition: types.h:16
Here is the call graph for this function:
Here is the caller graph for this function:

◆ db_disasm_esc()

static uintptr_t db_disasm_esc ( uintptr_t  loc,
int  inst,
int  rex,
int  short_addr,
int  size,
const char *  seg 
)
static

Definition at line 1095 of file disasm.c.

1096{
1097 int regmodrm;
1098 const struct finst * fp;
1099 int mod;
1100 struct i_addr address;
1101 const char * name;
1102
1103 get_value_inc(regmodrm, loc, 1, FALSE);
1104 fp = &db_Esc_inst[inst - 0xd8][f_reg(rex, regmodrm)];
1105 mod = f_mod(rex, regmodrm);
1106 if (mod != 3) {
1107 if (*fp->f_name == '\0') {
1108 kprintf("<bad instruction>");
1109 return (loc);
1110 }
1111 /*
1112 * Normal address modes.
1113 */
1114 loc = db_read_address(loc, short_addr, rex, regmodrm, &address);
1115 kprintf("%s", fp->f_name);
1116 switch(fp->f_size) {
1117 case SNGL:
1118 kprintf("s");
1119 break;
1120 case DBLR:
1121 kprintf("l");
1122 break;
1123 case EXTR:
1124 kprintf("t");
1125 break;
1126 case WORD:
1127 kprintf("s");
1128 break;
1129 case LONG:
1130 kprintf("l");
1131 break;
1132 case QUAD:
1133 kprintf("q");
1134 break;
1135 default:
1136 break;
1137 }
1138 kprintf("\t");
1139 db_print_address(seg, BYTE, rex, &address);
1140 }
1141 else {
1142 /*
1143 * 'reg-reg' - special formats
1144 */
1145 switch (fp->f_rrmode) {
1146 case op2(ST,STI):
1147 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1148 kprintf("%s\t%%st,%%st(%d)",name,f_rm(rex, regmodrm));
1149 break;
1150 case op2(STI,ST):
1151 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1152 kprintf("%s\t%%st(%d),%%st",name, f_rm(rex, regmodrm));
1153 break;
1154 case op1(STI):
1155 name = (fp->f_rrname) ? fp->f_rrname : fp->f_name;
1156 kprintf("%s\t%%st(%d)",name, f_rm(rex, regmodrm));
1157 break;
1158 case op1(X):
1159 name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
1160 if (*name == '\0')
1161 goto bad;
1162 kprintf("%s", name);
1163 break;
1164 case op1(XA):
1165 name = ((const char * const *)fp->f_rrname)[f_rm(rex, regmodrm)];
1166 if (*name == '\0')
1167 goto bad;
1168 kprintf("%s\t%%ax", name);
1169 break;
1170 default:
1171 bad:
1172 kprintf("<bad instruction>");
1173 break;
1174 }
1175 }
1176
1177 return (loc);
1178}
#define STI
Definition: disasm.c:106
#define X
Definition: disasm.c:107
#define XA
Definition: disasm.c:108
#define EXTR
Definition: disasm.c:56
const char * f_name
Definition: disasm.c:127
int f_rrmode
Definition: disasm.c:129
#define DBLR
Definition: disasm.c:55
#define op2(x, y)
Definition: disasm.c:123
int f_size
Definition: disasm.c:128
#define SNGL
Definition: disasm.c:54
#define op1(x)
Definition: disasm.c:122
#define ST
Definition: disasm.c:105
static const struct finst *const db_Esc_inst[]
Definition: disasm.c:578
Definition: disasm.c:126
Here is the call graph for this function:
Here is the caller graph for this function:

◆ db_print_address()

static void db_print_address ( const char *  seg,
int  size,
int  rex,
struct i_addr addrp 
)
static

Definition at line 1067 of file disasm.c.

1068{
1069 if (addrp->is_reg) {
1070 kprintf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][addrp->disp]);
1071 return;
1072 }
1073
1074 if (seg) {
1075 kprintf("%s:", seg);
1076 }
1077
1078 if (addrp->disp != 0 || (addrp->base == 0 && addrp->index == 0))
1080 if (addrp->base != 0 || addrp->index != 0) {
1081 kprintf("(");
1082 if (addrp->base)
1083 kprintf("%s", addrp->base);
1084 if (addrp->index)
1085 kprintf(",%s,%d", addrp->index, 1<<addrp->ss);
1086 kprintf(")");
1087 }
1088}
int disp
Definition: disasm.c:943
const char * base
Definition: disasm.c:944
int is_reg
Definition: disasm.c:942
const char * index
Definition: disasm.c:945
int ss
Definition: disasm.c:946
Here is the call graph for this function:
Here is the caller graph for this function:

◆ db_read_address()

static uintptr_t db_read_address ( uintptr_t  loc,
int  short_addr,
int  rex,
int  regmodrm,
struct i_addr addrp 
)
static

Definition at line 1004 of file disasm.c.

1005{
1006 int mod, rm, sib, index, disp, size, have_sib;
1007
1008 mod = f_mod(rex, regmodrm);
1009 rm = f_rm(rex, regmodrm);
1010
1011 if (mod == 3) {
1012 addrp->is_reg = TRUE;
1013 addrp->disp = rm;
1014 return (loc);
1015 }
1016 addrp->is_reg = FALSE;
1017 addrp->index = 0;
1018
1019 if (short_addr)
1020 size = LONG;
1021 else
1022 size = QUAD;
1023
1024 if ((rm & 0x7) == 4) {
1025 get_value_inc(sib, loc, 1, FALSE);
1026 rm = sib_base(rex, sib);
1027 index = sib_index(rex, sib);
1028 if (index != 4)
1029 addrp->index = db_reg[1][size][index];
1030 addrp->ss = sib_ss(rex, sib);
1031 have_sib = 1;
1032 } else
1033 have_sib = 0;
1034
1035 switch (mod) {
1036 case 0:
1037 if (rm == 5) {
1038 get_value_inc(addrp->disp, loc, 4, FALSE);
1039 if (have_sib)
1040 addrp->base = 0;
1041 else if (short_addr)
1042 addrp->base = "%eip";
1043 else
1044 addrp->base = "%rip";
1045 } else {
1046 addrp->disp = 0;
1047 addrp->base = db_reg[1][size][rm];
1048 }
1049 break;
1050
1051 case 1:
1052 get_value_inc(disp, loc, 1, TRUE);
1053 addrp->disp = disp;
1054 addrp->base = db_reg[1][size][rm];
1055 break;
1056
1057 case 2:
1058 get_value_inc(disp, loc, 4, FALSE);
1059 addrp->disp = disp;
1060 addrp->base = db_reg[1][size][rm];
1061 break;
1062 }
1063 return (loc);
1064}
#define sib_ss(rex, byte)
Definition: disasm.c:937
#define sib_index(rex, byte)
Definition: disasm.c:938
#define sib_base(rex, byte)
Definition: disasm.c:939
Here is the caller graph for this function:

Variable Documentation

◆ db_bad_inst

const struct inst db_bad_inst
static
Initial value:
=
{ "???", FALSE, NONE, 0, 0 }

Definition at line 929 of file disasm.c.

◆ db_Esc8

const struct finst db_Esc8[]
static
Initial value:
= {
{ "fadd", SNGL, op2(STI,ST), 0 },
{ "fmul", SNGL, op2(STI,ST), 0 },
{ "fcom", SNGL, op2(STI,ST), 0 },
{ "fcomp", SNGL, op2(STI,ST), 0 },
{ "fsub", SNGL, op2(STI,ST), 0 },
{ "fsubr", SNGL, op2(STI,ST), 0 },
{ "fdiv", SNGL, op2(STI,ST), 0 },
{ "fdivr", SNGL, op2(STI,ST), 0 },
}

Definition at line 490 of file disasm.c.

◆ db_Esc9

const struct finst db_Esc9[]
static
Initial value:
= {
{ "fld", SNGL, op1(STI), 0 },
{ "", NONE, op1(STI), "fxch" },
{ "fst", SNGL, op1(X), db_Esc92 },
{ "fstp", SNGL, 0, 0 },
{ "fldenv", NONE, op1(X), db_Esc94 },
{ "fldcw", NONE, op1(X), db_Esc95 },
{ "fnstenv",NONE, op1(X), db_Esc96 },
{ "fnstcw", NONE, op1(X), db_Esc97 },
}
static const char *const db_Esc97[]
Definition: disasm.c:470
static const char *const db_Esc95[]
Definition: disasm.c:463
static const char *const db_Esc94[]
Definition: disasm.c:460
static const char *const db_Esc92[]
Definition: disasm.c:457
static const char *const db_Esc96[]
Definition: disasm.c:466

Definition at line 501 of file disasm.c.

◆ db_Esc92

const char* const db_Esc92[]
static
Initial value:
= {
"fnop", "", "", "", "", "", "", ""
}

Definition at line 457 of file disasm.c.

◆ db_Esc94

const char* const db_Esc94[]
static
Initial value:
= {
"fchs", "fabs", "", "", "ftst", "fxam", "", ""
}

Definition at line 460 of file disasm.c.

◆ db_Esc95

const char* const db_Esc95[]
static
Initial value:
= {
"fld1", "fldl2t","fldl2e","fldpi","fldlg2","fldln2","fldz",""
}

Definition at line 463 of file disasm.c.

◆ db_Esc96

const char* const db_Esc96[]
static
Initial value:
= {
"f2xm1","fyl2x","fptan","fpatan","fxtract","fprem1","fdecstp",
"fincstp"
}

Definition at line 466 of file disasm.c.

◆ db_Esc97

const char* const db_Esc97[]
static
Initial value:
= {
"fprem","fyl2xp1","fsqrt","fsincos","frndint","fscale","fsin","fcos"
}

Definition at line 470 of file disasm.c.

◆ db_Esc_inst

const struct finst* const db_Esc_inst[]
static
Initial value:
= {
}
static const struct finst db_Escc[]
Definition: disasm.c:534
static const struct finst db_Esc8[]
Definition: disasm.c:490
static const struct finst db_Esca[]
Definition: disasm.c:512
static const struct finst db_Esce[]
Definition: disasm.c:556
static const struct finst db_Escb[]
Definition: disasm.c:523
static const struct finst db_Escf[]
Definition: disasm.c:567
static const struct finst db_Esc9[]
Definition: disasm.c:501
static const struct finst db_Escd[]
Definition: disasm.c:545

Definition at line 578 of file disasm.c.

◆ db_Esca

const struct finst db_Esca[]
static
Initial value:
= {
{ "fiadd", LONG, 0, 0 },
{ "fimul", LONG, 0, 0 },
{ "ficom", LONG, 0, 0 },
{ "ficomp", LONG, 0, 0 },
{ "fisub", LONG, 0, 0 },
{ "fisubr", LONG, op1(X), db_Esca5 },
{ "fidiv", LONG, 0, 0 },
{ "fidivr", LONG, 0, 0 }
}
static const char *const db_Esca5[]
Definition: disasm.c:474

Definition at line 512 of file disasm.c.

◆ db_Esca5

const char* const db_Esca5[]
static
Initial value:
= {
"", "fucompp","", "", "", "", "", ""
}

Definition at line 474 of file disasm.c.

◆ db_Escb

const struct finst db_Escb[]
static
Initial value:
= {
{ "fild", LONG, 0, 0 },
{ "", NONE, 0, 0 },
{ "fist", LONG, 0, 0 },
{ "fistp", LONG, 0, 0 },
{ "", WORD, op1(X), db_Escb4 },
{ "fld", EXTR, 0, 0 },
{ "", WORD, 0, 0 },
{ "fstp", EXTR, 0, 0 },
}
static const char *const db_Escb4[]
Definition: disasm.c:478

Definition at line 523 of file disasm.c.

◆ db_Escb4

const char* const db_Escb4[]
static
Initial value:
= {
"fneni","fndisi", "fnclex","fninit","fsetpm", "", "", ""
}

Definition at line 478 of file disasm.c.

◆ db_Escc

const struct finst db_Escc[]
static
Initial value:
= {
{ "fadd", DBLR, op2(ST,STI), 0 },
{ "fmul", DBLR, op2(ST,STI), 0 },
{ "fcom", DBLR, 0, 0 },
{ "fcomp", DBLR, 0, 0 },
{ "fsub", DBLR, op2(ST,STI), "fsubr" },
{ "fsubr", DBLR, op2(ST,STI), "fsub" },
{ "fdiv", DBLR, op2(ST,STI), "fdivr" },
{ "fdivr", DBLR, op2(ST,STI), "fdiv" },
}

Definition at line 534 of file disasm.c.

◆ db_Escd

const struct finst db_Escd[]
static
Initial value:
= {
{ "fld", DBLR, op1(STI), "ffree" },
{ "", NONE, 0, 0 },
{ "fst", DBLR, op1(STI), 0 },
{ "fstp", DBLR, op1(STI), 0 },
{ "frstor", NONE, op1(STI), "fucom" },
{ "", NONE, op1(STI), "fucomp" },
{ "fnsave", NONE, 0, 0 },
{ "fnstsw", NONE, 0, 0 },
}

Definition at line 545 of file disasm.c.

◆ db_Esce

const struct finst db_Esce[]
static
Initial value:
= {
{ "fiadd", WORD, op2(ST,STI), "faddp" },
{ "fimul", WORD, op2(ST,STI), "fmulp" },
{ "ficom", WORD, 0, 0 },
{ "ficomp", WORD, op1(X), db_Esce3 },
{ "fisub", WORD, op2(ST,STI), "fsubrp" },
{ "fisubr", WORD, op2(ST,STI), "fsubp" },
{ "fidiv", WORD, op2(ST,STI), "fdivrp" },
{ "fidivr", WORD, op2(ST,STI), "fdivp" },
}
static const char *const db_Esce3[]
Definition: disasm.c:482

Definition at line 556 of file disasm.c.

◆ db_Esce3

const char* const db_Esce3[]
static
Initial value:
= {
"", "fcompp","", "", "", "", "", ""
}

Definition at line 482 of file disasm.c.

◆ db_Escf

const struct finst db_Escf[]
static
Initial value:
= {
{ "fild", WORD, 0, 0 },
{ "", NONE, 0, 0 },
{ "fist", WORD, 0, 0 },
{ "fistp", WORD, 0, 0 },
{ "fbld", NONE, op1(XA), db_Escf4 },
{ "fild", QUAD, 0, 0 },
{ "fbstp", NONE, 0, 0 },
{ "fistp", QUAD, 0, 0 },
}
static const char *const db_Escf4[]
Definition: disasm.c:486

Definition at line 567 of file disasm.c.

◆ db_Escf4

const char* const db_Escf4[]
static
Initial value:
= {
"fnstsw","", "", "", "", "", "", ""
}

Definition at line 486 of file disasm.c.

◆ db_Grp1

const char* const db_Grp1[]
static
Initial value:
= {
"add",
"or",
"adc",
"sbb",
"and",
"sub",
"xor",
"cmp"
}

Definition at line 583 of file disasm.c.

◆ db_Grp15

const char* const db_Grp15[]
static
Initial value:
= {
"fxsave",
"fxrstor",
"ldmxcsr",
"stmxcsr",
"xsave",
"xrstor",
"xsaveopt",
"clflush"
}

Definition at line 217 of file disasm.c.

◆ db_Grp15b

const char* const db_Grp15b[]
static
Initial value:
= {
"",
"",
"",
"",
"",
"lfence",
"mfence",
"sfence"
}

Definition at line 228 of file disasm.c.

◆ db_Grp2

const char* const db_Grp2[]
static
Initial value:
= {
"rol",
"ror",
"rcl",
"rcr",
"shl",
"shr",
"shl",
"sar"
}

Definition at line 594 of file disasm.c.

◆ db_Grp3

const struct inst db_Grp3[]
static
Initial value:
= {
{ "test", TRUE, NONE, op2(I,E), 0 },
{ "test", TRUE, NONE, op2(I,E), 0 },
{ "not", TRUE, NONE, op1(E), 0 },
{ "neg", TRUE, NONE, op1(E), 0 },
{ "mul", TRUE, NONE, op2(E,A), 0 },
{ "imul", TRUE, NONE, op2(E,A), 0 },
{ "div", TRUE, NONE, op2(E,A), 0 },
{ "idiv", TRUE, NONE, op2(E,A), 0 },
}

Definition at line 605 of file disasm.c.

◆ db_Grp4

const struct inst db_Grp4[]
static
Initial value:
= {
{ "inc", TRUE, BYTE, op1(E), 0 },
{ "dec", TRUE, BYTE, op1(E), 0 },
{ "", TRUE, NONE, 0, 0 },
{ "", TRUE, NONE, 0, 0 },
{ "", TRUE, NONE, 0, 0 },
{ "", TRUE, NONE, 0, 0 },
{ "", TRUE, NONE, 0, 0 },
{ "", TRUE, NONE, 0, 0 }
}

Definition at line 616 of file disasm.c.

◆ db_Grp5

const struct inst db_Grp5[]
static
Initial value:
= {
{ "inc", TRUE, LONG, op1(E), 0 },
{ "dec", TRUE, LONG, op1(E), 0 },
{ "call", TRUE, LONG, op1(Eind),0 },
{ "lcall", TRUE, LONG, op1(Eind),0 },
{ "jmp", TRUE, LONG, op1(Eind),0 },
{ "ljmp", TRUE, LONG, op1(Eind),0 },
{ "push", TRUE, LONG, op1(E), 0 },
{ "", TRUE, NONE, 0, 0 }
}

Definition at line 627 of file disasm.c.

◆ db_Grp6

const char* const db_Grp6[]
static
Initial value:
= {
"sldt",
"str",
"lldt",
"ltr",
"verr",
"verw",
"",
""
}

Definition at line 173 of file disasm.c.

◆ db_Grp7

const char* const db_Grp7[]
static
Initial value:
= {
"sgdt",
"sidt",
"lgdt",
"lidt",
"smsw",
"",
"lmsw",
"invlpg"
}

Definition at line 184 of file disasm.c.

◆ db_Grp8

const char* const db_Grp8[]
static
Initial value:
= {
"",
"",
"",
"",
"bt",
"bts",
"btr",
"btc"
}

Definition at line 195 of file disasm.c.

◆ db_Grp9

const char* const db_Grp9[]
static
Initial value:
= {
"",
"cmpxchg8b",
"",
"",
"",
"",
"vmptrld",
"vmptrst"
}

Definition at line 206 of file disasm.c.

◆ db_inst_0f

const struct inst* const db_inst_0f[]
static
Initial value:
= {
0,
0,
0,
0,
0,
0
}
static const struct inst db_inst_0f3x[]
Definition: disasm.c:279
static const struct inst db_inst_0f7x[]
Definition: disasm.c:319
static const struct inst db_inst_0f0x[]
Definition: disasm.c:239
static const struct inst db_inst_0f9x[]
Definition: disasm.c:359
static const struct inst db_inst_0f4x[]
Definition: disasm.c:299
static const struct inst db_inst_0fbx[]
Definition: disasm.c:399
static const struct inst db_inst_0f8x[]
Definition: disasm.c:339
static const struct inst db_inst_0fax[]
Definition: disasm.c:379
static const struct inst db_inst_0f2x[]
Definition: disasm.c:259
static const struct inst db_inst_0fcx[]
Definition: disasm.c:419

Definition at line 438 of file disasm.c.

◆ db_inst_0f0x

const struct inst db_inst_0f0x[]
static
Initial value:
= {
{ "", TRUE, NONE, op1(Ew), db_Grp6 },
{ "", TRUE, NONE, op1(Ew), db_Grp7 },
{ "lar", TRUE, LONG, op2(E,R), 0 },
{ "lsl", TRUE, LONG, op2(E,R), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "syscall",FALSE,NONE, 0, 0 },
{ "clts", FALSE, NONE, 0, 0 },
{ "sysret",FALSE, NONE, 0, 0 },
{ "invd", FALSE, NONE, 0, 0 },
{ "wbinvd",FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
}

Definition at line 239 of file disasm.c.

◆ db_inst_0f2x

const struct inst db_inst_0f2x[]
static
Initial value:
= {
{ "mov", TRUE, LONG, op2(CR,El), 0 },
{ "mov", TRUE, LONG, op2(DR,El), 0 },
{ "mov", TRUE, LONG, op2(El,CR), 0 },
{ "mov", TRUE, LONG, op2(El,DR), 0 },
{ "mov", TRUE, LONG, op2(TR,El), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "mov", TRUE, LONG, op2(El,TR), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
}

Definition at line 259 of file disasm.c.

◆ db_inst_0f38

const struct inst* const db_inst_0f38[]
static
Initial value:
= {
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
}
static const struct inst db_inst_0f388x[]
Definition: disasm.c:134

Definition at line 154 of file disasm.c.

◆ db_inst_0f388x

const struct inst db_inst_0f388x[]
static
Initial value:
= {
{ "", TRUE, SDEP, op2(E, Rq), "invept" },
{ "", TRUE, SDEP, op2(E, Rq), "invvpid" },
{ "", TRUE, SDEP, op2(E, Rq), "invpcid" },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
}

Definition at line 134 of file disasm.c.

◆ db_inst_0f3x

const struct inst db_inst_0f3x[]
static
Initial value:
= {
{ "wrmsr", FALSE, NONE, 0, 0 },
{ "rdtsc", FALSE, NONE, 0, 0 },
{ "rdmsr", FALSE, NONE, 0, 0 },
{ "rdpmc", FALSE, NONE, 0, 0 },
{ "sysenter",FALSE,NONE, 0, 0 },
{ "sysexit",FALSE,NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "getsec",FALSE, NONE, 0, 0 },
{ "", FALSE, ESC, 0, db_inst_0f38 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
}
static const struct inst *const db_inst_0f38[]
Definition: disasm.c:154

Definition at line 279 of file disasm.c.

◆ db_inst_0f4x

const struct inst db_inst_0f4x[]
static
Initial value:
= {
{ "cmovo", TRUE, NONE, op2(E, R), 0 },
{ "cmovno", TRUE, NONE, op2(E, R), 0 },
{ "cmovb", TRUE, NONE, op2(E, R), 0 },
{ "cmovnb", TRUE, NONE, op2(E, R), 0 },
{ "cmovz", TRUE, NONE, op2(E, R), 0 },
{ "cmovnz", TRUE, NONE, op2(E, R), 0 },
{ "cmovbe", TRUE, NONE, op2(E, R), 0 },
{ "cmovnbe",TRUE, NONE, op2(E, R), 0 },
{ "cmovs", TRUE, NONE, op2(E, R), 0 },
{ "cmovns", TRUE, NONE, op2(E, R), 0 },
{ "cmovp", TRUE, NONE, op2(E, R), 0 },
{ "cmovnp", TRUE, NONE, op2(E, R), 0 },
{ "cmovl", TRUE, NONE, op2(E, R), 0 },
{ "cmovnl", TRUE, NONE, op2(E, R), 0 },
{ "cmovle", TRUE, NONE, op2(E, R), 0 },
{ "cmovnle",TRUE, NONE, op2(E, R), 0 },
}

Definition at line 299 of file disasm.c.

◆ db_inst_0f7x

const struct inst db_inst_0f7x[]
static
Initial value:
= {
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "vmread", TRUE, NONE, op2(Rq, E), 0 },
{ "vmwrite",TRUE, NONE, op2(E, Rq), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
}

Definition at line 319 of file disasm.c.

◆ db_inst_0f8x

const struct inst db_inst_0f8x[]
static
Initial value:
= {
{ "jo", FALSE, NONE, op1(Dl), 0 },
{ "jno", FALSE, NONE, op1(Dl), 0 },
{ "jb", FALSE, NONE, op1(Dl), 0 },
{ "jnb", FALSE, NONE, op1(Dl), 0 },
{ "jz", FALSE, NONE, op1(Dl), 0 },
{ "jnz", FALSE, NONE, op1(Dl), 0 },
{ "jbe", FALSE, NONE, op1(Dl), 0 },
{ "jnbe", FALSE, NONE, op1(Dl), 0 },
{ "js", FALSE, NONE, op1(Dl), 0 },
{ "jns", FALSE, NONE, op1(Dl), 0 },
{ "jp", FALSE, NONE, op1(Dl), 0 },
{ "jnp", FALSE, NONE, op1(Dl), 0 },
{ "jl", FALSE, NONE, op1(Dl), 0 },
{ "jnl", FALSE, NONE, op1(Dl), 0 },
{ "jle", FALSE, NONE, op1(Dl), 0 },
{ "jnle", FALSE, NONE, op1(Dl), 0 },
}

Definition at line 339 of file disasm.c.

◆ db_inst_0f9x

const struct inst db_inst_0f9x[]
static
Initial value:
= {
{ "seto", TRUE, NONE, op1(Eb), 0 },
{ "setno", TRUE, NONE, op1(Eb), 0 },
{ "setb", TRUE, NONE, op1(Eb), 0 },
{ "setnb", TRUE, NONE, op1(Eb), 0 },
{ "setz", TRUE, NONE, op1(Eb), 0 },
{ "setnz", TRUE, NONE, op1(Eb), 0 },
{ "setbe", TRUE, NONE, op1(Eb), 0 },
{ "setnbe",TRUE, NONE, op1(Eb), 0 },
{ "sets", TRUE, NONE, op1(Eb), 0 },
{ "setns", TRUE, NONE, op1(Eb), 0 },
{ "setp", TRUE, NONE, op1(Eb), 0 },
{ "setnp", TRUE, NONE, op1(Eb), 0 },
{ "setl", TRUE, NONE, op1(Eb), 0 },
{ "setnl", TRUE, NONE, op1(Eb), 0 },
{ "setle", TRUE, NONE, op1(Eb), 0 },
{ "setnle",TRUE, NONE, op1(Eb), 0 },
}

Definition at line 359 of file disasm.c.

◆ db_inst_0fax

const struct inst db_inst_0fax[]
static
Initial value:
= {
{ "push", FALSE, NONE, op1(Si), 0 },
{ "pop", FALSE, NONE, op1(Si), 0 },
{ "cpuid", FALSE, NONE, 0, 0 },
{ "bt", TRUE, LONG, op2(R,E), 0 },
{ "shld", TRUE, LONG, op3(Ib,R,E), 0 },
{ "shld", TRUE, LONG, op3(CL,R,E), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "push", FALSE, NONE, op1(Si), 0 },
{ "pop", FALSE, NONE, op1(Si), 0 },
{ "rsm", FALSE, NONE, 0, 0 },
{ "bts", TRUE, LONG, op2(R,E), 0 },
{ "shrd", TRUE, LONG, op3(Ib,R,E), 0 },
{ "shrd", TRUE, LONG, op3(CL,R,E), 0 },
{ "", TRUE, LONG, op1(E), db_Grp15 },
{ "imul", TRUE, LONG, op2(E,R), 0 },
}
#define op3(x, y, z)
Definition: disasm.c:124

Definition at line 379 of file disasm.c.

◆ db_inst_0fbx

const struct inst db_inst_0fbx[]
static
Initial value:
= {
{ "cmpxchg",TRUE, BYTE, op2(R, E), 0 },
{ "cmpxchg",TRUE, LONG, op2(R, E), 0 },
{ "lss", TRUE, LONG, op2(E, R), 0 },
{ "btr", TRUE, LONG, op2(R, E), 0 },
{ "lfs", TRUE, LONG, op2(E, R), 0 },
{ "lgs", TRUE, LONG, op2(E, R), 0 },
{ "movzb", TRUE, LONG, op2(Eb, R), 0 },
{ "movzw", TRUE, LONG, op2(Ew, R), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", TRUE, LONG, op2(Ib, E), db_Grp8 },
{ "btc", TRUE, LONG, op2(R, E), 0 },
{ "bsf", TRUE, LONG, op2(E, R), 0 },
{ "bsr", TRUE, LONG, op2(E, R), 0 },
{ "movsb", TRUE, LONG, op2(Eb, R), 0 },
{ "movsw", TRUE, LONG, op2(Ew, R), 0 },
}

Definition at line 399 of file disasm.c.

◆ db_inst_0fcx

const struct inst db_inst_0fcx[]
static
Initial value:
= {
{ "xadd", TRUE, BYTE, op2(R, E), 0 },
{ "xadd", TRUE, LONG, op2(R, E), 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", FALSE, NONE, 0, 0 },
{ "", TRUE, NONE, op1(E), db_Grp9 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
{ "bswap", FALSE, LONG, op1(Ril), 0 },
}

Definition at line 419 of file disasm.c.

◆ db_inst_table

const struct inst db_inst_table[256]
static

Definition at line 638 of file disasm.c.

◆ db_lengths

const int db_lengths[]
static
Initial value:
= {
1,
2,
4,
8,
4,
8,
10,
}

Definition at line 977 of file disasm.c.

◆ db_reg

const char* const db_reg[2][4][16]
static
Initial value:
= {
{{"%al", "%cl", "%dl", "%bl", "%ah", "%ch", "%dh", "%bh",
"%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
{ "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
"%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
{ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
"%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
{ "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }},
{{"%al", "%cl", "%dl", "%bl", "%spl", "%bpl", "%sil", "%dil",
"%r8b", "%r9b", "%r10b", "%r11b", "%r12b", "%r13b", "%r14b", "%r15b" },
{ "%ax", "%cx", "%dx", "%bx", "%sp", "%bp", "%si", "%di",
"%r8w", "%r9w", "%r10w", "%r11w", "%r12w", "%r13w", "%r14w", "%r15w" },
{ "%eax", "%ecx", "%edx", "%ebx", "%esp", "%ebp", "%esi", "%edi",
"%r8d", "%r9d", "%r10d", "%r11d", "%r12d", "%r13d", "%r14d", "%r15d" },
{ "%rax", "%rcx", "%rdx", "%rbx", "%rsp", "%rbp", "%rsi", "%rdi",
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15" }}
}

Definition at line 949 of file disasm.c.

◆ db_seg_reg

const char* const db_seg_reg[8]
static
Initial value:
= {
"%es", "%cs", "%ss", "%ds", "%fs", "%gs", "", ""
}

Definition at line 970 of file disasm.c.