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

View File

@ -116,3 +116,19 @@ ins REG -- inc, dec, not, div, mul
ins MEM -- ^
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;

View File

@ -44,19 +44,20 @@ static const char * operation_name [] = {
"fsub", "fsubr", "fdiv", "fdivr",
"rol", "ror", "rcl", "rcr",
"sal", "shr", "shl", "sar",
"nop", "retn", "retf", "leave",
"popf", "pushf", "cwde", "cdqe",
"nop", "cwde", "popf", "pushf",
"halt", "lock", "wait", "leave",
"cmc", "clc", "cld", "cli",
"stc", "std", "sti", "lock",
"int3", "iretn", "iretf", "wait",
"syscall", "cpuid", "fnop", "fchs",
"stc", "std", "sti",
"retn", "retf",
"syscall", "sysenter", "sysretn", "sysexitn",
"cpuid", "cdqe", "rsm", "ud2",
"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",
"fsin", "fcos",
"enter", "call", "in", "out",
"jmp", "mov", "pop", "push",
"jo", "jno", "jb", "jae",
@ -71,14 +72,14 @@ static const char * operation_name [] = {
"sete", "setne", "setbe", "seta",
"sets", "setns", "setpe", "setpo",
"setl", "setge", "setle", "setg",
"lea", "movbe",
"test", "ud2", "xadd", "xchg",
//~"lea", "movbe",
//~"test", "ud2", "xadd", "xchg",
"bt", "bts", "btr", "btc",
"bsf", "bsr", "bswap",
"loop", "loope", "loopne",
"rep", "repe", "repne",
"ins", "outs", "lods", "stos",
"movs", "cmps", "scas"
//~"rep", "repe", "repne",
//~"ins", "outs", "lods", "stos",
//~"movs", "cmps", "scas"
};
#endif
@ -337,7 +338,9 @@ static int build_static_1(const int * restrict array) {
const int operation = array[0];
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]);
@ -351,10 +354,13 @@ static int build_static_2(const int * restrict array) {
const int operation = array[0];
const unsigned short data[] = {
0x050f, 0xa20f, 0xd0d9, 0xe0d9, 0xe1d9, 0xe4d9, 0xe5d9, 0xe8d9,
0xe9d9, 0xead9, 0xebd9, 0xecd9, 0xedd9, 0xeed9, 0xf0d9, 0xf1d9,
0xf2d9, 0xf3d9, 0xf4d9, 0xf5d9, 0xf6d9, 0xf7d9, 0xf8d9, 0xf9d9,
0xfad9, 0xfbd9, 0xfcd9, 0xfdd9, 0xfed9, 0xffd9
SYSCALL, SYSENTER, SYSRETN, SYSEXITN,
CPUID, CDQE, RSM, UD2,
0x050f, 0x340f, 0x070f, 0x350f, 0xa20f, 0x9848, 0xaa0f, 0x0b0f,
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]);
@ -797,7 +803,12 @@ static int (*build_instruction[])(const int * restrict array) = {
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_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,
@ -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_enter, build_call, build_in_out, build_in_out,
build_jump, build_move, build_pop, build_push,
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,
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,
//~CMC, CLC, CLD, CLI,
//~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_scan, build_bit_scan, build_swap,
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,
//~INS, OUTS, LODS, STOS,
//~MOVS, CMPS, SCAS

View File

@ -54,31 +54,31 @@ enum {
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,
//~FBLD, FBSTP,
//~FADDP, FIADD,
//~FCMOVB, FCMOVE, FCMOVBE, FCMOVU,
//~FCMOVAE, FCMOVNE, FCMOVA, FCMOVNU,
//~FCOMI, FCOMIP, FUCOMI, FUCOMIP,
//~FDIVP, FIDIV, FDIVRP, FIDIVR,
//~FFREE, FICOM, FICOMP, FILD,
//~FIST, FISTP,
//~FISTTP, FLD, FLDCW, FLDENV,
//~FMULP, FIMUL, FRSTOR, FUCOM,
//~FSAVE, FNSAVE, FST, FSTP,
//~FSTCW, FNSTCW, FSTENV, FNSTENV,
//~FSTSW, FNSTSW, FSUBP, FISUB,
//~FSUBRP, FISUBR, FUCOMP,
/**/
HALT, LOCK, WAIT, LEAVE,
NOP, CWDE, POPF, PUSHF,
HALT, LOCK, WAIT, LEAVE,
CMC, CLC, CLD, CLI,
STC, STD, STI, INT3,
RETN, RETF, IRETN, IRETF,
STC, STD, STI,
RETN, RETF,
/**/
SYSCALL, SYSENTER, SYSRETN, SYSEXITN,
CPUID, CDQE, RSM, UD2,
EMMS, PAUSE, INVD, WBINVD,
WRMSR, RDMSR, RDPMC, RDTSC,
//~EMMS, PAUSE, INVD, WBINVD,
//~WRMSR, RDMSR, RDPMC, RDTSC,
FNOP, FCHS, FSIN, FCOS,
FABS, FTST, FXAM, FLD1,
FLDL2T, FLDL2E, FLDPI, FLDLG2,
@ -86,14 +86,15 @@ enum {
FPTAN, FPATAN, FXTRACT, FPREM1,
FDECSTP, FINCSTP, FPREM, FYL2XP1,
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,
JMP, MOV, POP, PUSH,
RETNPOP, RETFPOP,
//~RETNPOP, RETFPOP,
// C2 [2B] CA [2B]
JO, JNO, JB, JAE,
JE, JNE, JBE, JA,
@ -107,14 +108,15 @@ enum {
SETE, SETNE, SETBE, SETA,
SETS, SETNS, SETPE, SETPO,
SETL, SETGE, SETLE, SETG,
LEA, MOVBE,
TEST, XADD, XCHG, BSWAP,
//~LEA, MOVBE,
//~TEST, XADD, XCHG, /*BSWAP,*/
BT, BTS, BTR, BTC,
BSF, BSR, SHLD, SHRD,
BSF, BSR, BSWAP,
//~SHLD, SHRD,
LOOP, LOOPE, LOOPNE,
REP, REPE, REPNE,
INS, OUTS, LODS, STOS,
MOVS, CMPS, SCAS
//~REP, REPE, REPNE,
//~INS, OUTS, LODS, STOS,
//~MOVS, CMPS, SCAS
// 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.
};

BIN
tool/xop Executable file

Binary file not shown.

31
tool/xop.pas Normal file
View 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.