aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/insn.rs14
-rw-r--r--src/insn/pop.rs14
-rw-r--r--src/insn/push.rs14
3 files changed, 42 insertions, 0 deletions
diff --git a/src/insn.rs b/src/insn.rs
index c7e6e7e..60004d2 100644
--- a/src/insn.rs
+++ b/src/insn.rs
@@ -9,6 +9,8 @@ mod jnz;
mod jz;
mod mov;
mod nop;
+mod pop;
+mod push;
mod ret;
mod test;
@@ -63,6 +65,18 @@ pub trait Mov<T, U> {
fn mov(&mut self, op1: T, op2: U);
}
+/// Trait for [`push`](https://www.felixcloutier.com/x86/push) instruction kinds.
+pub trait Push<T> {
+ /// Emit a push instruction.
+ fn push(&mut self, op1: T);
+}
+
+/// Trait for [`pop`](https://www.felixcloutier.com/x86/pop) instruction kinds.
+pub trait Pop<T> {
+ /// Emit a pop instruction.
+ fn pop(&mut self, op1: T);
+}
+
/// Trait for [`test`](https://www.felixcloutier.com/x86/test) instruction kinds.
pub trait Test<T, U> {
/// Emit a logical compare instruction.
diff --git a/src/insn/pop.rs b/src/insn/pop.rs
new file mode 100644
index 0000000..c8cc5b5
--- /dev/null
+++ b/src/insn/pop.rs
@@ -0,0 +1,14 @@
+use super::Pop;
+use crate::{Asm, Reg16, Reg64};
+
+impl Pop<Reg64> for Asm {
+ fn pop(&mut self, op1: Reg64) {
+ self.encode_r(0x8f, 0x0, op1);
+ }
+}
+
+impl Pop<Reg16> for Asm {
+ fn pop(&mut self, op1: Reg16) {
+ self.encode_r(0x8f, 0x0, op1);
+ }
+}
diff --git a/src/insn/push.rs b/src/insn/push.rs
new file mode 100644
index 0000000..8554dcb
--- /dev/null
+++ b/src/insn/push.rs
@@ -0,0 +1,14 @@
+use super::Push;
+use crate::{Asm, Reg16, Reg64};
+
+impl Push<Reg64> for Asm {
+ fn push(&mut self, op1: Reg64) {
+ self.encode_r(0xff, 0x6, op1);
+ }
+}
+
+impl Push<Reg16> for Asm {
+ fn push(&mut self, op1: Reg16) {
+ self.encode_r(0xff, 0x6, op1);
+ }
+}