compiler_m68k.c 775 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. Cell* execute_jitted(void* binary) {
  2. return (Cell*)((funcptr)binary)(0);
  3. }
  4. void memdump(void* start,uint32_t len,int raw);
  5. int compile_for_platform(Cell* expr, Cell** res) {
  6. int codesz = 8192;
  7. int success = 0;
  8. register void* sp __asm ("sp");
  9. Frame empty_frame = {NULL, 0, 0, sp};
  10. code = malloc(codesz);
  11. memset(code, 0, codesz);
  12. jit_init();
  13. success = compile_expr(expr, &empty_frame, TAG_ANY);
  14. jit_ret();
  15. if (success) {
  16. printf("<assembled at: %p>\r\n",code);
  17. //memdump(code,64,0);
  18. /*if (bytes_read>codesz) {
  19. printf("<error: max assembly size of %d exhausted. aborting>\n",codesz);
  20. return 0;
  21. }*/
  22. *res = execute_jitted(code);
  23. //printf("res: %p\r\n",*res);
  24. success = 1;
  25. }
  26. return success;
  27. }