mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-01-12 02:29:48 +00:00
Refactoring to support (future) string asm.
This commit is contained in:
parent
dfb3bd1fca
commit
dc1e2bf829
@ -27,13 +27,13 @@ assemble_init(bus_t *b, uint16_t pc)
|
||||
}
|
||||
|
||||
bool
|
||||
assemble_single_implied(assembler_t *a, const char *mnemonic)
|
||||
assemble_single_implied(assembler_t *a, char *mnemonic)
|
||||
{
|
||||
return assemble_single(a, mnemonic, IMPLIED, 0, 0);
|
||||
}
|
||||
|
||||
bool
|
||||
assemble_single(assembler_t *a, const char *mnemonic, addressing_t mode, uint8_t op1, uint8_t op2)
|
||||
assemble_single(assembler_t *a, char *mnemonic, addressing_t mode, uint8_t op1, uint8_t op2)
|
||||
{
|
||||
uint8_t *asmbuf;
|
||||
uint8_t bsize;
|
||||
@ -50,31 +50,22 @@ assemble_single(assembler_t *a, const char *mnemonic, addressing_t mode, uint8_t
|
||||
}
|
||||
|
||||
bool
|
||||
assemble_single_buf_implied(uint8_t **buf, uint8_t *bsize, const char *mnemonic)
|
||||
assemble_single_buf_implied(uint8_t **buf, uint8_t *bsize, char *mnemonic)
|
||||
{
|
||||
return assemble_single_buf(buf, bsize, mnemonic, IMPLIED, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
assemble_single_buf(uint8_t **buf, uint8_t *bsize, const char *mnemonic, addressing_t mode, uint8_t op1, uint8_t op2)
|
||||
assemble_single_buf(uint8_t **buf, uint8_t *bsize, char *mnemonic, addressing_t mode, uint8_t op1, uint8_t op2)
|
||||
{
|
||||
instrdef_t id;
|
||||
uint8_t opcode;
|
||||
bool found;
|
||||
|
||||
found = false;
|
||||
opcode = 0;
|
||||
|
||||
/* find the opcode for given mnemonic and addressing mode */
|
||||
while (opcode <= 0xFF) { /* this is stupid */
|
||||
id = instruction_decode(opcode);
|
||||
if ((strcmp(mnemonic, id.mnemonic) == 0) && (id.mode == mode)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
opcode++;
|
||||
}
|
||||
found = instruction_opcode_by_mnemonic(mnemonic, mode, &opcode, &id);
|
||||
|
||||
if (!found) {
|
||||
rk65c02_log(LOG_ERROR,
|
||||
|
@ -11,12 +11,12 @@ struct assembler {
|
||||
|
||||
typedef struct assembler assembler_t;
|
||||
|
||||
bool assemble_single_buf_implied(uint8_t **, uint8_t *, const char *);
|
||||
bool assemble_single_buf(uint8_t **, uint8_t *, const char *, addressing_t, uint8_t, uint8_t);
|
||||
bool assemble_single_buf_implied(uint8_t **, uint8_t *, char *);
|
||||
bool assemble_single_buf(uint8_t **, uint8_t *, char *, addressing_t, uint8_t, uint8_t);
|
||||
|
||||
assembler_t assemble_init(bus_t *, uint16_t);
|
||||
bool assemble_single(assembler_t *, const char *, addressing_t, uint8_t, uint8_t);
|
||||
bool assemble_single_implied(assembler_t *, const char *);
|
||||
bool assemble_single(assembler_t *, char *, addressing_t, uint8_t, uint8_t);
|
||||
bool assemble_single_implied(assembler_t *, char *);
|
||||
|
||||
#endif /* _ASSEMBLER_H_ */
|
||||
|
||||
|
@ -311,3 +311,23 @@ instruction_modify_pc(instrdef_t *id)
|
||||
return id->modify_pc;
|
||||
}
|
||||
|
||||
/* find instr definition (and opcode) searching by mnemonic and addr mode */
|
||||
bool
|
||||
instruction_opcode_by_mnemonic(char *mnemonic, addressing_t mode, uint8_t *opcode, instrdef_t *id)
|
||||
{
|
||||
bool found;
|
||||
|
||||
found = false;
|
||||
|
||||
while ((*opcode) <= 0xFF) { /* this is stupid */
|
||||
*id = instruction_decode(*opcode);
|
||||
if ((strcmp(mnemonic, id->mnemonic) == 0) && (id->mode == mode)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
(*opcode)++;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
@ -56,5 +56,6 @@ uint8_t stack_pop(rk65c02emu_t *);
|
||||
void program_counter_increment(rk65c02emu_t *, instrdef_t *);
|
||||
bool instruction_modify_pc(instrdef_t *);
|
||||
void program_counter_branch(rk65c02emu_t *, int8_t);
|
||||
bool instruction_opcode_by_mnemonic(char *, addressing_t, uint8_t *, instrdef_t *);
|
||||
|
||||
#endif /* _INSTRUCTION_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user