summaryrefslogtreecommitdiffhomepage
path: root/test-asm.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-10-18 18:38:26 +0200
committerRoland Reichwein <mail@reichwein.it>2020-10-18 18:38:26 +0200
commitfe722b9304052b7a0a67fe01633c24ba5b4cdafa (patch)
tree7656b558c4dea8221bff07377253c66ec9f79086 /test-asm.cpp
parent8a2d1dc5c8b6639985d26d1c915048d87d52426b (diff)
Implemented insertAddresses()
Diffstat (limited to 'test-asm.cpp')
-rw-r--r--test-asm.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/test-asm.cpp b/test-asm.cpp
index 256902c..efdeab9 100644
--- a/test-asm.cpp
+++ b/test-asm.cpp
@@ -93,12 +93,26 @@ TEST_F(AsmTest, Intel64_multiple) {
Segment segment;
segment.push_back(makeOp("nop"));
- AsmArgs args{{AsmArgs::Immediate8(5)}};
- segment.push_back(makeOp("int", args));
+ AsmArgs args0{{AsmArgs::Immediate8(5)}};
+ segment.push_back(makeOp("int", args0));
segment.push_back(makeOp("ret"));
segment.push_back(makeLabel("data1"));
+ segment.push_back(makeOp("ret"));
+ AsmArgs args1{{AsmArgs::Label("data1")}};
+ segment.push_back(makeOp("jmp", args1));
segment.push_back(makeData({1, 2, 3}));
- ASSERT_EQ(segment.size(), 5);
- ASSERT_EQ(segment.getCode(), std::vector<uint8_t>({0x90, 0xCD, 0x05, 0xC3, 0x01, 0x02, 0x03}));
+ segment.insertAddresses();
+
+ ASSERT_EQ(segment.size(), 7);
+ ASSERT_EQ(segment.getCode(), std::vector<uint8_t>(
+ {
+ 0x90, // nop
+ 0xCD, 0x05, // int 5
+ 0xC3, // ret
+ // data1:
+ 0xC3, // ret
+ 0xE9, 0xFF, 0xFF, 0xFF, 0xFF, // jmp data1
+ 0x01, 0x02, 0x03 // data
+ }));
}