Mercurial > repos > blastem
annotate disasm.h @ 2476:aaf7bb58ffca
Fix bug in Gen/MD serialize routine that could cause a use-after free in some cases
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 03 Mar 2024 13:47:59 -0800 |
parents | 4e27c36f947c |
children |
rev | line source |
---|---|
2206
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef DISASM_H_ |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define DISASM_H_ |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 #include <stdint.h> |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "tern.h" |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #include "backend.h" |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 typedef struct { |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 char **labels; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 uint32_t num_labels; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 uint32_t storage; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 uint32_t full_address; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 uint8_t referenced; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 } label_def; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 typedef struct { |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 tern_node *labels; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 uint8_t *visited; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 deferred_addr *deferred; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 uint32_t address_mask; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 uint32_t invalid_inst_addr_mask; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 uint32_t visit_preshift; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } disasm_context; |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 |
2213
53411df7fc71
More 68K disassembler refactoring and fix Windows build failure
Michael Pavone <pavone@retrodev.com>
parents:
2206
diff
changeset
|
25 typedef int (*format_label_fun)(char * dst, uint32_t address, disasm_context * context); |
53411df7fc71
More 68K disassembler refactoring and fix Windows build failure
Michael Pavone <pavone@retrodev.com>
parents:
2206
diff
changeset
|
26 |
2206
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 label_def *find_label(disasm_context *context, uint32_t address); |
2213
53411df7fc71
More 68K disassembler refactoring and fix Windows build failure
Michael Pavone <pavone@retrodev.com>
parents:
2206
diff
changeset
|
28 int format_label(char *dst, uint32_t address, disasm_context *context); |
2206
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 void weak_label(disasm_context *context, const char *name, uint32_t address); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 void reference(disasm_context *context, uint32_t address); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 void add_label(disasm_context *context, const char *name, uint32_t address); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 void visit(disasm_context *context, uint32_t address); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 uint8_t is_visited(disasm_context *context, uint32_t address); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 void defer_disasm(disasm_context *context, uint32_t address); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 void process_m68k_vectors(disasm_context *context, uint16_t *table, uint8_t labels_only); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 void add_segacd_maincpu_labels(disasm_context *context); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 void add_segacd_subcpu_labels(disasm_context *context); |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 disasm_context *create_68000_disasm(void); |
2216
4e27c36f947c
Add disassemble command to debugger
Michael Pavone <pavone@retrodev.com>
parents:
2213
diff
changeset
|
39 disasm_context *create_z80_disasm(void); |
2206
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 |
4c265d2f6c88
Minor refactor of 68K disassembler
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 #endif //DISASM_H_ |