|
33 | 33 | ¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸ |
34 | 34 | ¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯ |
35 | 35 | */ |
36 | | -#ifndef ETRIPATOR_OPCODES_H |
37 | | -#define ETRIPATOR_OPCODES_H |
| 36 | +#ifndef ETRIPATOR_DATA_H |
| 37 | +#define ETRIPATOR_DATA_H |
38 | 38 |
|
39 | 39 | #include "config.h" |
40 | 40 |
|
41 | | -/// @defgroup Opcode Opcode |
42 | | -///@{ |
| 41 | +/// @defgroup DataGroup Data access |
| 42 | +/// @{ |
43 | 43 |
|
44 | | -/// Opcode types: |
45 | | -/// -# `OPC` |
46 | | -/// -# `OPC A` |
47 | | -/// -# `OPC #nn` |
48 | | -/// -# `OPC #nn, ZZ` |
49 | | -/// -# `OPC #nn, ZZ, X` |
50 | | -/// -# `OPC #nn, hhll` |
51 | | -/// -# `OPC #nn, hhll, X` |
52 | | -/// -# `OPC ZZ` |
53 | | -/// -# `OPC ZZ, X` |
54 | | -/// -# `OPC ZZ, Y` |
55 | | -/// -# `OPC (ZZ)` |
56 | | -/// -# `OPC (ZZ, X)` |
57 | | -/// -# `OPC (ZZ), Y` |
58 | | -/// -# `OPC ZZ, hhll` |
59 | | -/// -# `OPC hhll` |
60 | | -/// -# `OPC (hhll)` |
61 | | -/// -# `OPC hhll, X` |
62 | | -/// -# `OPC hhll, Y` |
63 | | -/// -# `OPC shsl,dhdl,hhll` |
64 | | -/// -# `OPC l_hhll` (label) |
65 | | -/// -# `OPC ZZ, l_hhll` (label) |
66 | | -/// -# `OPC [hhll, X]` |
67 | | -/// -# `.db OPC` (unsupported opcode output as raw binary data) |
68 | | -enum PCE_ADDRESSING_MODE { |
69 | | - PCE_OP = 0, |
70 | | - PCE_OP_A, |
71 | | - PCE_OP_nn, |
72 | | - PCE_OP_nn_ZZ, |
73 | | - PCE_OP_nn_ZZ_X, |
74 | | - PCE_OP_nn_hhll, |
75 | | - PCE_OP_nn_hhll_X, |
76 | | - PCE_OP_ZZ, |
77 | | - PCE_OP_ZZ_X, |
78 | | - PCE_OP_ZZ_Y, |
79 | | - PCE_OP__ZZ__, |
80 | | - PCE_OP__ZZ_X__, |
81 | | - PCE_OP__ZZ__Y_, |
82 | | - PCE_OP_ZZ_hhll, |
83 | | - PCE_OP_hhll, |
84 | | - PCE_OP__hhll__, |
85 | | - PCE_OP_hhll_X, |
86 | | - PCE_OP_hhll_Y, |
87 | | - PCE_OP_shsl_dhdl_hhll, |
88 | | - PCE_OP__lbl__, |
89 | | - PCE_OP_ZZ_lbl, |
90 | | - PCE_OP__hhll_X__, |
91 | | - PCE_unknown |
92 | | -}; |
| 44 | +struct Data; |
| 45 | +typedef struct Data Data; |
93 | 46 |
|
94 | | -#define OPCODE_NAME_MAX_LEN 5U |
95 | | - |
96 | | -/// Opcode |
97 | | -typedef struct { |
98 | | - char name[OPCODE_NAME_MAX_LEN]; //< name |
99 | | - uint8_t size; //< size in bytes |
100 | | - uint8_t type; //< addressing type |
101 | | -} Opcode; |
102 | | - |
103 | | -/// Get opcode description |
104 | | -/// \param [in] op Opcode id |
105 | | -/// \return Pointer to opcode description |
106 | | -const Opcode* opcode_get(uint8_t op); |
107 | | - |
108 | | -/// Get opcode format string |
109 | | -/// \param [in] op Pointer to opcode description |
110 | | -/// \param [in] i Opcode argument id |
111 | | -/// \return Argument format string |
112 | | -/// \return NULL if the argument id is out of opcode argument count |
113 | | -const char* opcode_format(const Opcode *op, int i); |
114 | | - |
115 | | -/// Is the instruction a local jump ? |
116 | | -bool opcode_is_local_jump(uint8_t op); |
117 | | - |
118 | | -/// Is the instruction a "far" jump ? |
119 | | -bool opcode_is_far_jump(uint8_t op); |
| 47 | +/// Create in memory buffer data. |
| 48 | +/// @param [in] buffer Pointer to memory buffer. |
| 49 | +/// @param [in] size Memory buffer size. |
| 50 | +/// @return Pointer to memory buffer data. |
| 51 | +/// @return NULL if buffer is NULL or size is zero. |
| 52 | +Data* data_buffer_create(uint8_t *buffer, size_t size); |
| 53 | +/// Create file data. |
| 54 | +/// @param [in] filename File name. |
| 55 | +/// @param [in] mode [TODO] |
| 56 | +/// @return Pointer to file data. |
| 57 | +/// @return NULL [TODO] |
| 58 | +Data* data_file_create(const char *filename, const char* mode); |
| 59 | +/// |
| 60 | +void data_release(Data *data); |
| 61 | +/// |
| 62 | +bool data_open(Data *data); |
| 63 | +/// |
| 64 | +void data_close(Data *data); |
| 65 | +/// |
| 66 | +size_t data_tell(Data *data); |
| 67 | +/// |
| 68 | +size_t data_size(Data *data); |
| 69 | +/// |
| 70 | +bool data_seek(Data *data, ssize_t delta); |
| 71 | +/// |
| 72 | +bool data_jump(Data *data, ssize_t offset); |
| 73 | +/// |
| 74 | +bool data_read(Data *data, uint8_t *buffer, size_t size, size_t *nread); |
| 75 | +/// |
| 76 | +bool data_write(Data *data, const uint8_t *buffer, size_t size, size_t *nwritten); |
120 | 77 |
|
121 | 78 | /// @} |
122 | 79 |
|
123 | | -#endif // ETRIPATOR_OPCODES_H |
| 80 | +#endif // ETRIPATOR_DATA_H |
0 commit comments