So, I created a JIT code generation library for C++, and tried writing some useful code with it. I'm quite new to assembly programming, so its really hard for me to figure everything out by myself
Thing is, I created a Brainfuck-to-x64 compiler. One of Brainfuck's instructions (.) puts a character into stdout: I implemented it getting the address of putchar on C++ like this:
#include <cstdio>
uint_least64_t putchar_address = (uint_least64_t)&std::putchar;
And then generating code that would call the stored address on r10, example:
movq r10, 0x7ffe7ef1ab40
...
call r10
This works fine, however, I was thinking there might be a way to jump to that address without needing to waste a register through the whole program (and also having to push/pop the register before cdecl calls because these clobber r10, r11, etc)
Taking a look at compiled stdlib code shows they use things like call qword ptr [0xsomeaddress]?
Basically I need to hardcode the address on the call somehow, if that's even possible. Thanks in advance!