From 97b8d5bb3c9fd96251e89539d122d2331a2a7925 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Fri, 13 Nov 2020 11:27:39 +0100 Subject: Add system tests, implement syscall --- asm/intel64/all_ops.h | 3 +-- asm/intel64/nop.cpp | 11 ----------- asm/intel64/nop.h | 13 ------------- asm/intel64/ret.cpp | 12 ------------ asm/intel64/ret.h | 12 ------------ asm/intel64/trivials.cpp | 19 +++++++++++++++++++ asm/intel64/trivials.h | 24 ++++++++++++++++++++++++ 7 files changed, 44 insertions(+), 50 deletions(-) delete mode 100644 asm/intel64/nop.cpp delete mode 100644 asm/intel64/nop.h delete mode 100644 asm/intel64/ret.cpp delete mode 100644 asm/intel64/ret.h create mode 100644 asm/intel64/trivials.cpp create mode 100644 asm/intel64/trivials.h (limited to 'asm') diff --git a/asm/intel64/all_ops.h b/asm/intel64/all_ops.h index 82f518f..c41734c 100644 --- a/asm/intel64/all_ops.h +++ b/asm/intel64/all_ops.h @@ -10,7 +10,6 @@ #include "jmp.h" #include "mov.h" #include "mul.h" -#include "nop.h" -#include "ret.h" #include "sub.h" +#include "trivials.h" #include "xor.h" diff --git a/asm/intel64/nop.cpp b/asm/intel64/nop.cpp deleted file mode 100644 index 2d99278..0000000 --- a/asm/intel64/nop.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "nop.h" - -#include - -namespace { - -bool registered { registerOp("nop", [](Asm::Args& args) -> std::shared_ptr{ - return std::make_shared(); - }) }; - -} diff --git a/asm/intel64/nop.h b/asm/intel64/nop.h deleted file mode 100644 index 233b2ef..0000000 --- a/asm/intel64/nop.h +++ /dev/null @@ -1,13 +0,0 @@ -// No Operation - -#pragma once - -#include - -class Op_nop: public OpSimple -{ -public: - Op_nop() : OpSimple({ 0x90 }) {} - -}; - diff --git a/asm/intel64/ret.cpp b/asm/intel64/ret.cpp deleted file mode 100644 index c42ad8a..0000000 --- a/asm/intel64/ret.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "ret.h" - -#include - -namespace { - -bool registered { registerOp("ret", [](Asm::Args& args) -> std::shared_ptr{ - return std::make_shared(); - }) }; - -} - diff --git a/asm/intel64/ret.h b/asm/intel64/ret.h deleted file mode 100644 index 7e7f68c..0000000 --- a/asm/intel64/ret.h +++ /dev/null @@ -1,12 +0,0 @@ -// Return from procedure - -#pragma once - -#include - -class Op_ret: public OpSimple -{ -public: - Op_ret() : OpSimple({ 0xC3 }) {} // near return; TODO: far return is 0xCB -}; - diff --git a/asm/intel64/trivials.cpp b/asm/intel64/trivials.cpp new file mode 100644 index 0000000..dd89ecd --- /dev/null +++ b/asm/intel64/trivials.cpp @@ -0,0 +1,19 @@ +#include "trivials.h" + +#include + +namespace { + +bool registered { + registerOp("nop", [](Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(); + }) && + registerOp("ret", [](Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(); + }) && + registerOp("syscall", [](Asm::Args& args) -> std::shared_ptr{ + return std::make_shared(); + }) +}; + +} diff --git a/asm/intel64/trivials.h b/asm/intel64/trivials.h new file mode 100644 index 0000000..72ea3f8 --- /dev/null +++ b/asm/intel64/trivials.h @@ -0,0 +1,24 @@ +// Trivial Operations, without arguments + +#pragma once + +#include + +// No Operation +class Op_nop: public OpSimple +{ +public: Op_nop() : OpSimple({ 0x90 }) {} +}; + +// Return from procedure +class Op_ret: public OpSimple +{ +public: Op_ret() : OpSimple({ 0xC3 }) {} // near return; TODO: far return is 0xCB +}; + +// Syscall +class Op_syscall: public OpSimple +{ +public: Op_syscall() : OpSimple({ 0x0F, 0x05 }) {} +}; + -- cgit v1.2.3