Mercurial > repos > blastem
annotate x86_backend.c @ 271:969ee17471c5
Protect debug prints for busreq/reset regs with appropriate macros
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 02 May 2013 22:21:41 -0700 |
parents | d9bf8e61c33c |
children | 7b8a49220e3b |
rev | line source |
---|---|
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "x86_backend.h" |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #include <stdlib.h> |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 deferred_addr * new_head = malloc(sizeof(deferred_addr)); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 new_head->next = old_head; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 new_head->address = address & 0xFFFFFF; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 new_head->dest = dest; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 return new_head; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 deferred_addr * cur = *head_ptr; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 deferred_addr **last_next = head_ptr; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 while(cur) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 uint8_t * native = get_native(context, cur->address);//get_native_address(opts->native_code_map, cur->address); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 if (native) { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 int32_t disp = native - (cur->dest + 4); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 uint8_t * out = cur->dest; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 *out = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 *last_next = cur->next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 free(cur); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 cur = *last_next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 } else { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 last_next = &(cur->next); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 cur = cur->next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 |