#include "instructions.h" #include "registers.h" #include "write_elf.c" #include static const unsigned char exit_2[] = { // Exit syscall MOVWI(REG_EAX, SYS_exit), // Exit code MOVWI(REG_EDI, 0x02), SYSCALL }; static const unsigned char some_opcodes[] = { // rbx 00000001 MOVDI(REG_EBX, 0x1), // rcx 00000002 MOVBI(REG_CL, 0x2), // rcx 00000003 ADDB(REG_BL, REG_CL), // rcx 00000004 ADDW(REG_BX, REG_CX), // rcx 00000005 ADDD(REG_EBX, REG_ECX), // rcx 00000006 ADDQ(REG_EBX, REG_ECX), // rdi 00000006 MOVD(REG_ECX, REG_EDI), // Exit syscall MOVWI(REG_EAX, SYS_exit), SYSCALL }; static const unsigned int some_opcodes_len = sizeof(some_opcodes) / sizeof(some_opcodes[0]); int main(int argc, char* argv[]) { write_elf("test.out", some_opcodes_len, (char*)some_opcodes); return 0; }