Add example for memory operands

This commit is contained in:
ζeh Matt
2022-12-09 06:26:47 +02:00
parent aa36df2454
commit 3967ac3345
6 changed files with 239 additions and 296 deletions
+57
View File
@@ -0,0 +1,57 @@
#include "examples.common.hpp"
#include <iostream>
int main()
{
using namespace zasm;
Program program(MachineMode::AMD64);
x86::Assembler a(program);
auto labelTest = a.createLabel();
a.mov(x86::eax, x86::dword_ptr(x86::edx));
a.mov(x86::eax, x86::dword_ptr(x86::edx, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::ecx, x86::edx));
a.mov(x86::eax, x86::dword_ptr(x86::ecx, x86::edx, 2, 0xC));
a.mov(x86::eax, x86::dword_ptr(labelTest));
a.mov(x86::eax, x86::dword_ptr(labelTest, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::rip, labelTest));
a.mov(x86::eax, x86::dword_ptr(x86::rip, labelTest, 0xC));
a.mov(x86::eax, x86::dword_ptr(0x123456));
a.mov(x86::eax, x86::dword_ptr(x86::ds, x86::edx, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::ds, x86::edx, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::ds, x86::edx, x86::ecx));
a.mov(x86::eax, x86::dword_ptr(x86::ds, x86::edx, x86::ecx, 2, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::ds, labelTest, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::ds, x86::rip, labelTest));
a.mov(x86::eax, x86::dword_ptr(x86::ds, x86::rip, labelTest, 0xC));
a.mov(x86::eax, x86::dword_ptr(x86::fs, 0));
a.bind(labelTest);
Serializer serializer{};
auto res = serializer.serialize(program, 0x00400000);
assert(res == Error::None);
std::cout << examples::utils::getDisassemblyDump(serializer, program.getMode()) << "\n";
}