From 1ac8ab06e9aad3b6d22685255459d71cb49e1f28 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Mon, 9 Nov 2020 09:50:58 +0100 Subject: First program: Can add 2 integers and return result via exit code --- cpp.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cpp.cpp') diff --git a/cpp.cpp b/cpp.cpp index c988b5d..c8de4c8 100644 --- a/cpp.cpp +++ b/cpp.cpp @@ -1,6 +1,7 @@ #include "cpp.h" #include "asm/encode.h" +#include "asm/operators.h" #include "bnf.h" #include "cppbnf.h" #include "debug.h" @@ -584,13 +585,13 @@ void CPP::link() // TODO // mSegment -> elf -#if 0 - return { + + mCode = std::vector{ 0x48, 0xc7, 0xc0, 0x3c, 0x00, 0x00, 0x00, // mov $0x3c,%rax # syscall 60 0x48, 0x31, 0xff, // xor %rdi,%rdi # exit code 0 + } + mSegment.getCode() + std::vector{ // add to edi 0x0f, 0x05, // syscall }; -#endif } // phases of translation, according to standard -- cgit v1.2.3