Added Pascal xop and more things...

This commit is contained in:
xolatile 2024-11-22 14:14:10 -05:00
parent d7c7a3128d
commit 3869ab2bb2
5 changed files with 114 additions and 53 deletions

@ -116,3 +116,19 @@ ins REG -- inc, dec, not, div, mul
ins MEM -- ^ ins MEM -- ^
ins -- syscall, pause, hlt, ret, leave ins -- syscall, pause, hlt, ret, leave
``` ```
Current list of instructions:
ADD, OR, ADC, SBB, AND, SUB, XOR, CMP, INC, DEC, NOT, NEG, MUL, IMUL, DIV, IDIV, FADD, FMUL, FCOM, FCOMP, FSUB, FSUBR, FDIV, FDIVR, ROL, ROR,
RCL, RCR, SAL, SHR, SHL, SAR, FBLD, FBSTP, FADDP, FIADDP, FCLEX, FNCLEX, FCMOVB, FCMOVE, FCMOVBE, FCMOVU, FCMOVAE, FCMOVNE, FCMOVA, FCMOVNU,
FCOMI, FCOMIP, FUCOMI, FUCOMIP, FDIVP, FIDIV, FDIVRP, FIDIVR, FFREE, FICOM, FICOMP, FILD, FINIT, FNINIT, FIST, FISTP, FISTTP, FLD, FLDCW,
FLDENV, FMULP, FIMUL, FRSTOR, FUCOM, FSAVE, FNSAVE, FST, FSTP, FSTCW, FNSTCW, FSTENV, FNSTENV, FSTSW, FNSTSW, FSUBP, FISUB, FSUBRP, FISUBR,
FUCOMPP, FUCOMP, HALT, LOCK, WAIT, LEAVE, NOP, CWDE, POPF, PUSHF, CMC, CLC, CLD, CLI, STC, STD, STI, INT3, RETN, RETF, IRETN, IRETF, SYSCALL,
SYSENTER, SYSRETN, SYSEXITN, CPUID, CDQE, RSM, UD2, EMMS, PAUSE, INVD, WBINVD, WRMSR, RDMSR, RDPMC, RDTSC, FNOP, FCHS, FSIN, FCOS, FABS, FTST,
FXAM, FLD1, FLDL2T, FLDL2E, FLDPI, FLDLG2, FLDLN2, FLDZ, F2XM1, FYL2X, FPTAN, FPATAN, FXTRACT, FPREM1, FDECSTP, FINCSTP, FPREM, FYL2XP1, FSQRT,
FSINCOS, FRNDINT, FSCALE, FCOMPP, LFENCE, MFENCE, SFENCE, RDTSCP, MONITOR, MWAIT, SYSRETF, SYSEXITF, ENTER, CALL, IN, OUT, JMP, MOV, POP, PUSH,
RETNPOP, RETFPOP, JO, JNO, JB, JAE, JE, JNE, JBE, JA, JS, JNS, JPE, JPO, JL, JGE, JLE, JG, CMOVO, CMOVNO, CMOVB, CMOVAE, CMOVE, CMOVNE, CMOVBE,
CMOVA, CMOVS, CMOVNS, CMOVPE, CMOVPO, CMOVL, CMOVGE, CMOVLE, CMOVG, SETO, SETNO, SETB, SETAE, SETE, SETNE, SETBE, SETA, SETS, SETNS, SETPE,
SETPO, SETL, SETGE, SETLE, SETG, LEA, MOVBE, TEST, XADD, XCHG, BSWAP, BT, BTS, BTR, BTC, BSF, BSR, SHLD, SHRD, LOOP, LOOPE, LOOPNE, REP, REPE,
REPNE, INS, OUTS, LODS, STOS, MOVS, CMPS, SCAS;

@ -44,19 +44,20 @@ static const char * operation_name [] = {
"fsub", "fsubr", "fdiv", "fdivr", "fsub", "fsubr", "fdiv", "fdivr",
"rol", "ror", "rcl", "rcr", "rol", "ror", "rcl", "rcr",
"sal", "shr", "shl", "sar", "sal", "shr", "shl", "sar",
"nop", "retn", "retf", "leave", "nop", "cwde", "popf", "pushf",
"popf", "pushf", "cwde", "cdqe", "halt", "lock", "wait", "leave",
"cmc", "clc", "cld", "cli", "cmc", "clc", "cld", "cli",
"stc", "std", "sti", "lock", "stc", "std", "sti",
"int3", "iretn", "iretf", "wait", "retn", "retf",
"syscall", "cpuid", "fnop", "fchs", "syscall", "sysenter", "sysretn", "sysexitn",
"cpuid", "cdqe", "rsm", "ud2",
"fnop", "fchs", "fsin", "fcos",
"fabs", "ftst", "fxam", "fld1", "fabs", "ftst", "fxam", "fld1",
"fldl2t", "fldl2e", "fldpi", "fldlg2", "fldl2t", "fldl2e", "fldpi", "fldlg2",
"fldln2", "fldz", "f2xm1", "fyl2x", "fldln2", "fldz", "f2xm1", "fyl2x",
"fptan", "fpatan", "fxtract", "fprem1", "fptan", "fpatan", "fxtract", "fprem1",
"fdecstp", "fincstp", "fprem", "fyl2xp1", "fdecstp", "fincstp", "fprem", "fyl2xp1",
"fsqrt", "fsincos", "frndint", "fscale", "fsqrt", "fsincos", "frndint", "fscale",
"fsin", "fcos",
"enter", "call", "in", "out", "enter", "call", "in", "out",
"jmp", "mov", "pop", "push", "jmp", "mov", "pop", "push",
"jo", "jno", "jb", "jae", "jo", "jno", "jb", "jae",
@ -71,14 +72,14 @@ static const char * operation_name [] = {
"sete", "setne", "setbe", "seta", "sete", "setne", "setbe", "seta",
"sets", "setns", "setpe", "setpo", "sets", "setns", "setpe", "setpo",
"setl", "setge", "setle", "setg", "setl", "setge", "setle", "setg",
"lea", "movbe", //~"lea", "movbe",
"test", "ud2", "xadd", "xchg", //~"test", "ud2", "xadd", "xchg",
"bt", "bts", "btr", "btc", "bt", "bts", "btr", "btc",
"bsf", "bsr", "bswap", "bsf", "bsr", "bswap",
"loop", "loope", "loopne", "loop", "loope", "loopne",
"rep", "repe", "repne", //~"rep", "repe", "repne",
"ins", "outs", "lods", "stos", //~"ins", "outs", "lods", "stos",
"movs", "cmps", "scas" //~"movs", "cmps", "scas"
}; };
#endif #endif
@ -337,7 +338,9 @@ static int build_static_1(const int * restrict array) {
const int operation = array[0]; const int operation = array[0];
const unsigned char data[] = { const unsigned char data[] = {
0x90, 0xc3, 0xcb, 0xc9, 0x9d, 0x9c 0x90, 0x98, 0x9d, 0x9c, 0xf4, 0xf0, 0x9b, 0xc9,
0xf5, 0xf8, 0xfc, 0xfa, 0xf9, 0xfd, 0xfb,
0xc3, 0xcb
}; };
debug_print("@y%s@-", operation_name [operation]); debug_print("@y%s@-", operation_name [operation]);
@ -351,10 +354,13 @@ static int build_static_2(const int * restrict array) {
const int operation = array[0]; const int operation = array[0];
const unsigned short data[] = { const unsigned short data[] = {
0x050f, 0xa20f, 0xd0d9, 0xe0d9, 0xe1d9, 0xe4d9, 0xe5d9, 0xe8d9, SYSCALL, SYSENTER, SYSRETN, SYSEXITN,
0xe9d9, 0xead9, 0xebd9, 0xecd9, 0xedd9, 0xeed9, 0xf0d9, 0xf1d9, CPUID, CDQE, RSM, UD2,
0xf2d9, 0xf3d9, 0xf4d9, 0xf5d9, 0xf6d9, 0xf7d9, 0xf8d9, 0xf9d9, 0x050f, 0x340f, 0x070f, 0x350f, 0xa20f, 0x9848, 0xaa0f, 0x0b0f,
0xfad9, 0xfbd9, 0xfcd9, 0xfdd9, 0xfed9, 0xffd9 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000
}; };
debug_print("@y%s@-", operation_name [operation]); debug_print("@y%s@-", operation_name [operation]);
@ -797,7 +803,12 @@ static int (*build_instruction[])(const int * restrict array) = {
build_float, build_float, build_float, build_float, build_float, build_float, build_float, build_float,
build_shift, build_shift, build_shift, build_shift, build_shift, build_shift, build_shift, build_shift,
build_shift, build_shift, build_shift, build_shift, build_shift, build_shift, build_shift, build_shift,
//~build_static_1, build_static_1, build_static_1, build_static_1,
//~build_static_1, build_static_1,
build_static_1, build_static_1, build_static_1, build_static_1, build_static_1, build_static_1, build_static_1, build_static_1,
build_static_1, build_static_1, build_static_1, build_static_1,
build_static_1, build_static_1, build_static_1, build_static_1,
build_static_1, build_static_1, build_static_1,
build_static_1, build_static_1, build_static_1, build_static_1,
build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2,
build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2,
@ -806,7 +817,8 @@ static int (*build_instruction[])(const int * restrict array) = {
build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2,
build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2,
build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2,
build_static_2, build_static_2, build_static_2, build_static_2, build_static_2, build_static_2,
build_static_2, build_static_2, build_static_2, build_static_2,
build_enter, build_call, build_in_out, build_in_out, build_enter, build_call, build_in_out, build_in_out,
build_jump, build_move, build_pop, build_push, build_jump, build_move, build_pop, build_push,
build_jump_if, build_jump_if, build_jump_if, build_jump_if, build_jump_if, build_jump_if, build_jump_if, build_jump_if,
@ -821,10 +833,10 @@ static int (*build_instruction[])(const int * restrict array) = {
build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if,
build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if,
build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if, build_set_if,
NULL, NULL, NULL, NULL, //~NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, //~NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, //~NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, //~NULL, NULL, NULL, NULL,
//~LEA, CWDE, CDQE, //~LEA, CWDE, CDQE,
//~CMC, CLC, CLD, CLI, //~CMC, CLC, CLD, CLI,
//~MOVBE, STC, STD, STI, //~MOVBE, STC, STD, STI,
@ -832,9 +844,9 @@ static int (*build_instruction[])(const int * restrict array) = {
build_bit_test, build_bit_test, build_bit_test, build_bit_test, build_bit_test, build_bit_test, build_bit_test, build_bit_test,
build_bit_scan, build_bit_scan, build_swap, build_bit_scan, build_bit_scan, build_swap,
build_loop, build_loop, build_loop, build_loop, build_loop, build_loop,
NULL, NULL, NULL, //~NULL, NULL, NULL,
NULL, NULL, NULL, NULL, //~NULL, NULL, NULL, NULL,
NULL, NULL, NULL //~NULL, NULL, NULL
//~REP, REPE, REPNE, //~REP, REPE, REPNE,
//~INS, OUTS, LODS, STOS, //~INS, OUTS, LODS, STOS,
//~MOVS, CMPS, SCAS //~MOVS, CMPS, SCAS

@ -54,31 +54,31 @@ enum {
ROL, ROR, RCL, RCR, ROL, ROR, RCL, RCR,
SAL, SHR, SHL, SAR, SAL, SHR, SHL, SAR,
/**/ /**/
FBLD, FBSTP, //~FBLD, FBSTP,
FADDP, FIADDP, FCLEX, FNCLEX, //~FADDP, FIADD,
FCMOVB, FCMOVE, FCMOVBE, FCMOVU, //~FCMOVB, FCMOVE, FCMOVBE, FCMOVU,
FCMOVAE, FCMOVNE, FCMOVA, FCMOVNU, //~FCMOVAE, FCMOVNE, FCMOVA, FCMOVNU,
FCOMI, FCOMIP, FUCOMI, FUCOMIP, //~FCOMI, FCOMIP, FUCOMI, FUCOMIP,
FDIVP, FIDIV, FDIVRP, FIDIVR, //~FDIVP, FIDIV, FDIVRP, FIDIVR,
FFREE, FICOM, FICOMP, FILD, //~FFREE, FICOM, FICOMP, FILD,
FINIT, FNINIT, FIST, FISTP, //~FIST, FISTP,
FISTTP, FLD, FLDCW, FLDENV, //~FISTTP, FLD, FLDCW, FLDENV,
FMULP, FIMUL, FRSTOR, FUCOM, //~FMULP, FIMUL, FRSTOR, FUCOM,
FSAVE, FNSAVE, FST, FSTP, //~FSAVE, FNSAVE, FST, FSTP,
FSTCW, FNSTCW, FSTENV, FNSTENV, //~FSTCW, FNSTCW, FSTENV, FNSTENV,
FSTSW, FNSTSW, FSUBP, FISUB, //~FSTSW, FNSTSW, FSUBP, FISUB,
FSUBRP, FISUBR, FUCOMPP, FUCOMP, //~FSUBRP, FISUBR, FUCOMP,
/**/ /**/
HALT, LOCK, WAIT, LEAVE,
NOP, CWDE, POPF, PUSHF, NOP, CWDE, POPF, PUSHF,
HALT, LOCK, WAIT, LEAVE,
CMC, CLC, CLD, CLI, CMC, CLC, CLD, CLI,
STC, STD, STI, INT3, STC, STD, STI,
RETN, RETF, IRETN, IRETF, RETN, RETF,
/**/ /**/
SYSCALL, SYSENTER, SYSRETN, SYSEXITN, SYSCALL, SYSENTER, SYSRETN, SYSEXITN,
CPUID, CDQE, RSM, UD2, CPUID, CDQE, RSM, UD2,
EMMS, PAUSE, INVD, WBINVD, //~EMMS, PAUSE, INVD, WBINVD,
WRMSR, RDMSR, RDPMC, RDTSC, //~WRMSR, RDMSR, RDPMC, RDTSC,
FNOP, FCHS, FSIN, FCOS, FNOP, FCHS, FSIN, FCOS,
FABS, FTST, FXAM, FLD1, FABS, FTST, FXAM, FLD1,
FLDL2T, FLDL2E, FLDPI, FLDLG2, FLDL2T, FLDL2E, FLDPI, FLDLG2,
@ -86,14 +86,15 @@ enum {
FPTAN, FPATAN, FXTRACT, FPREM1, FPTAN, FPATAN, FXTRACT, FPREM1,
FDECSTP, FINCSTP, FPREM, FYL2XP1, FDECSTP, FINCSTP, FPREM, FYL2XP1,
FSQRT, FSINCOS, FRNDINT, FSCALE, FSQRT, FSINCOS, FRNDINT, FSCALE,
FCOMPP, //~FCOMPP, FUCOMPP, FINIT, FNINIT,
//~FCLEX, FNCLEX,
/**/ /**/
LFENCE, MFENCE, SFENCE, RDTSCP, //~MONITOR, MWAIT, SYSRETF, SYSEXITF,
MONITOR, MWAIT, SYSRETF, SYSEXITF, //~LFENCE, MFENCE, SFENCE, RDTSCP,
/**/ /**/
ENTER, CALL, IN, OUT, ENTER, CALL, IN, OUT,
JMP, MOV, POP, PUSH, JMP, MOV, POP, PUSH,
RETNPOP, RETFPOP, //~RETNPOP, RETFPOP,
// C2 [2B] CA [2B] // C2 [2B] CA [2B]
JO, JNO, JB, JAE, JO, JNO, JB, JAE,
JE, JNE, JBE, JA, JE, JNE, JBE, JA,
@ -107,14 +108,15 @@ enum {
SETE, SETNE, SETBE, SETA, SETE, SETNE, SETBE, SETA,
SETS, SETNS, SETPE, SETPO, SETS, SETNS, SETPE, SETPO,
SETL, SETGE, SETLE, SETG, SETL, SETGE, SETLE, SETG,
LEA, MOVBE, //~LEA, MOVBE,
TEST, XADD, XCHG, BSWAP, //~TEST, XADD, XCHG, /*BSWAP,*/
BT, BTS, BTR, BTC, BT, BTS, BTR, BTC,
BSF, BSR, SHLD, SHRD, BSF, BSR, BSWAP,
//~SHLD, SHRD,
LOOP, LOOPE, LOOPNE, LOOP, LOOPE, LOOPNE,
REP, REPE, REPNE, //~REP, REPE, REPNE,
INS, OUTS, LODS, STOS, //~INS, OUTS, LODS, STOS,
MOVS, CMPS, SCAS //~MOVS, CMPS, SCAS
// The REP prefix can be added to the INS, OUTS, MOVS, LODS, and STOS instructions. // The REP prefix can be added to the INS, OUTS, MOVS, LODS, and STOS instructions.
// The REPE and REPNE prefixes can be added to the CMPS and SCAS instructions. // The REPE and REPNE prefixes can be added to the CMPS and SCAS instructions.
}; };

BIN
tool/xop Executable file

Binary file not shown.

31
tool/xop.pas Normal file

@ -0,0 +1,31 @@
(* Copyright (c) 2036 - John 'Daddy' Backus *)
(* Pascal program for printing file bytes. *)
(* If byte is equal to 0x90, then new line. *)
program xop;
uses
sysutils;
var
data: file of byte;
code: byte;
begin
assign (data, paramstr (1));
reset (data);
while not eof (data) do
begin
read (data, code);
if code = 144 then
begin
writeln;
end;
write (inttohex (code, 2));
write (' ');
end;
writeln;
close (data);
end.