Add pushad/popad instructions to assembler.
R=sebmarchand@chromium.org, chrisha@chromium.org
Review URL: https://codereview.appspot.com/136990043
git-svn-id: http://sawbuck.googlecode.com/svn/trunk@2283 15e8cca8-e42c-11de-a347-f34a4f72eb7d
diff --git a/syzygy/core/assembler.cc b/syzygy/core/assembler.cc
index 6b8317d..dd88834 100644
--- a/syzygy/core/assembler.cc
+++ b/syzygy/core/assembler.cc
@@ -851,6 +851,12 @@
instr.EmitOperand(0x6, dst);
}
+void AssemblerImpl::pushad() {
+ InstructionBuffer instr(this);
+
+ instr.EmitOpCodeByte(0x60);
+}
+
void AssemblerImpl::pop(const Register32& src) {
InstructionBuffer instr(this);
@@ -864,6 +870,12 @@
instr.EmitOperand(0, dst);
}
+void AssemblerImpl::popad() {
+ InstructionBuffer instr(this);
+
+ instr.EmitOpCodeByte(0x61);
+}
+
void AssemblerImpl::pushfd() {
InstructionBuffer instr(this);
instr.EmitOpCodeByte(0x9C);
diff --git a/syzygy/core/assembler.h b/syzygy/core/assembler.h
index b20c600..1b2eba2 100644
--- a/syzygy/core/assembler.h
+++ b/syzygy/core/assembler.h
@@ -256,12 +256,14 @@
void push(const Register32& src);
void push(const ImmediateImpl& src);
void push(const OperandImpl& src);
+ void pushad();
void pop(const Register32& dst);
void pop(const OperandImpl& dst);
+ void popad();
// @}
- // @name Manipulation of flags.
+ // @name Flag manipulation.
// @{
void pushfd();
void popfd();
diff --git a/syzygy/core/assembler_unittest.cc b/syzygy/core/assembler_unittest.cc
index e892c41..20c68c8 100644
--- a/syzygy/core/assembler_unittest.cc
+++ b/syzygy/core/assembler_unittest.cc
@@ -731,6 +731,9 @@
// General push, try one variant as the rest are OperandImpl encodings.
asm_.push(OperandImpl(DisplacementImpl(0xCAFEBABE, kSize32Bit, NULL)));
EXPECT_BYTES(0xFF, 0x35, 0xBE, 0xBA, 0xFE, 0xCA);
+
+ asm_.pushad();
+ EXPECT_BYTES(0x60);
}
TEST_F(AssemblerTest, Pop) {
@@ -748,6 +751,9 @@
// General pop, try one variant as the rest are OperandImpl encodings.
asm_.pop(OperandImpl(DisplacementImpl(0xCAFEBABE, kSize32Bit, NULL)));
EXPECT_BYTES(0x8F, 0x05, 0xBE, 0xBA, 0xFE, 0xCA);
+
+ asm_.popad();
+ EXPECT_BYTES(0x61);
}
TEST_F(AssemblerTest, Flags) {