Questions tagged [asmjit]

AsmJit is a complete JIT and remote assembler for C++ language.

AsmJit is a complete JIT and remote assembler for C++ language. It can generate native code for x86 and x64 architectures having support for a full instruction set, from legacy MMX to the newest AVX2. It has a type-safe API that allows C++ compiler to do a semantic checks at compile-time even before the assembled code is generated or run.

20 questions
6
votes
2 answers

gcc -D option not doing what I thought it would

I'm trying to use AsmJit in a project. This is the makefile I was using: CC = g++ CFLAGS = -D ASMJIT_API -I dep/ test: src/main.cpp $(CC) $(CFLAGS) src/main.cpp -o test.exe I was getting compiler errors when trying this, so instead I…
flumpb
  • 1,707
  • 3
  • 16
  • 33
2
votes
1 answer

Moving 64bit constants to memory

I am playing around with asmjit and generating assembly. Thereby I noticed that one can not use 64bit constants for instructions (excluding mov which makes sense). Because of that, I push 64bit constants to the stack and use them by accessing the…
jagemue
  • 363
  • 4
  • 16
2
votes
1 answer

AsmJit equivalent of mov eax,[ecx+0CC]

What is the asmjit equivalent of mov eax,[ecx+0CC]? This is close: c.mov_ptr(x86::eax, x86::ptr(x86::ecx, 0x0CC)); but the arguments are wrong. Any ideas?
Christian Stewart
  • 15,217
  • 20
  • 82
  • 139
1
vote
0 answers

AsmJit how to get raw bytes

How to encode the instruction like this mov eax, 0x00123456 and get b8 56 34 12 00? I know how to encode but how to get the output in the buffer using AsmJit because encoding manually is not a good way to solve problem? It can be done more easily…
Aligator
  • 11
  • 2
1
vote
1 answer

AsmJit emit bytes or x64 absolute far jump

I want to emit absolute far jump using asmjit. Bytes of this jump: FF 25 00 00 00 00 // jmp qword ptr [null offset] 00 00 00 00 00 00 00 00 // 8-byte jump target address But I don't know how to emit jmp qword ptr [*] with 0 offset and raw address…
rabtors
  • 75
  • 5
1
vote
0 answers

ASMJIT incorrect pointer

cc.addFunc(FuncSignatureT()); X86Gp state_ref = cc.newUIntPtr(); cc.setArg(0, state_ref); CCFuncCall* print_call = cc.call(imm_ptr(printf), FuncSignatureT()); print_call->setArg(0, imm_ptr("state:…
Jujhar Singh
  • 373
  • 5
  • 16
1
vote
1 answer

How to embed asmjit into own C++ project?

I am new to asmjit (and somewhat new to C++), and right now I am trying to just get asmjit working within my C++ project. I am using a Windows machine with Visual Studio 17 and C++17, and my first attempt using cmake already worked fine. However,…
Duke
  • 410
  • 7
  • 15
1
vote
1 answer

Error when using AsmJit within a Qt GUI Application

OS: Windows 10 IDE: Visual Studio 2015 I need to use the AsmJit library (https://github.com/asmjit/asmjit) inside my Qt GUI Application. But is is somehow incompatible. When certain headers are included from QT (QWidget etc.), things start to…
Steffen Brem
  • 1,738
  • 18
  • 29
1
vote
1 answer

How to get current instruction in asmjit?

According to this post, in x64, you can perform lea rax, [rip] to get the current instruction. How would I do this using asmjit?
0
votes
0 answers

What is causing this EXC_BAD_ACCESS (code=EXC_I386_GPFLT)

I'm using asmjit to JIT compile a scripting language to X86-64 machine code. When I jump into my JIT compiled functions, they seem to work, but when they call one of my C++ functions, which in turn call printf (or cout), the program crashes. I can't…
Rob N
  • 15,024
  • 17
  • 92
  • 165
0
votes
0 answers

Loading absolute pointer to register via LEA

How to load an absolute address to register via lea? I tried this code: asm.lea(asmjit::x86::rax, (uint64_t) (address)); And I try to use this code asm.lea(asmjit::x86::rax, asmjit::x86::ptr((uint64_t) (address))); But all of them don't work.…
0
votes
1 answer

How does asmjit get code relocation when use AsmParser(&a).parse

I use asmjit in my c++ code and defined a function like below: // parse asm_str to byte code, return the length of byte code int assemble(bool isx64, unsigned long long addr, const char* asm_str, char buffer[MAX_INSTRUCTION_LENGTH]) { …
0
votes
1 answer

Set XMM register via address location for X86-64

I have a float value at some address in memory, and I want to set an XMM register to that value by using the address. I'm using asmjit. This code works for a 32 bit build and sets the XMM register v to the correct value *f: using namespace…
Duke
  • 410
  • 7
  • 15
0
votes
0 answers

Calling C++ member function by assembly (using asmjit)

I'm just experimenting with some JIT compilation, using the asmjit library. Specifically, I want to call a member function of a class instance using the address of that instance as an argument for the jitted function. I understand that I have to use…
jagemue
  • 363
  • 4
  • 16
0
votes
1 answer

How can I use the library that I have built without error from source, but not compiling for my own project?

I'd like to try the AsmJit library. Building it with 'cmake' and 'make' from source was no problem, the examples it provided were all compiled and executed perfectly. I also did make install to export the dependency files. I then wanted to compile…
Foxy
  • 980
  • 8
  • 17
1
2