Mercurial > repos > blastem
view test_x86.c @ 14:2bdad0f52f42
x86 code gen, initial work on translator
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 27 Nov 2012 09:28:13 -0800 |
parents | |
children | c0f339564819 |
line wrap: on
line source
#include "gen_x86.h" #include <stdio.h> #include <stddef.h> int main(int argc, char ** argv) { uint8_t foo[512]; uint8_t *cur = foo, *end; cur = mov_rr(cur, RAX, RBX, SZ_B); cur = mov_rr(cur, RCX, RDX, SZ_B); cur = mov_rr(cur, R8, R9, SZ_B); cur = mov_rr(cur, R8, RAX, SZ_B); cur = mov_rr(cur, RAX, RBX, SZ_W); cur = mov_rr(cur, R11, R12, SZ_W); cur = mov_rr(cur, RAX, RBX, SZ_D); cur = mov_rr(cur, RAX, RBX, SZ_Q); cur = mov_i32r(cur, 5, RAX); cur = mov_i32r(cur, 3, R8); cur = mov_i8r(cur, 4, RSP); cur = add_rr(cur, RAX, RBX, SZ_D); cur = add_i8r(cur, 5, RAX); cur = add_i8r(cur, 5, RBX); cur = pushf(cur); cur = popf(cur); cur = setcc_r(cur, CC_S, RBX); cur = setcc_r(cur, CC_Z, RDX); cur = setcc_r(cur, CC_O, BH); cur = setcc_r(cur, CC_C, DH); cur = setcc_rind(cur, CC_C, RSI); cur = mov_rrdisp8(cur, RCX, RSI, offsetof(m68k_context, dregs) + 4 * sizeof(uint32_t), SZ_D); cur = mov_rdisp8r(cur, RSI, offsetof(m68k_context, dregs) + 5 * sizeof(uint32_t), RCX, SZ_D); cur = mov_rrind(cur, DH, RSI, SZ_B); cur = jcc(cur, CC_NZ, -2); cur = jcc(cur, CC_Z, 0); cur = jcc(cur, CC_LE, 0x7CA); for (end = cur, cur = foo; cur != end; cur++) { printf(" %X", *cur); } puts(""); return 0; }