1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-12-25 03:32:22 +00:00

Add function to return true if an instruction would write to memory

This commit is contained in:
Peter Evans 2018-04-21 23:15:48 -05:00
parent 37f9e627ba
commit c53c7bfd1d
2 changed files with 17 additions and 0 deletions

View File

@ -166,6 +166,7 @@ typedef vm_8bit (*mos6502_address_resolver)(mos6502 *);
typedef void (*mos6502_instruction_handler)(mos6502 *, vm_8bit); typedef void (*mos6502_instruction_handler)(mos6502 *, vm_8bit);
extern bool mos6502_would_jump(int); extern bool mos6502_would_jump(int);
extern bool mos6502_would_write_mem(int);
extern int mos6502_cycles(mos6502 *, vm_8bit); extern int mos6502_cycles(mos6502 *, vm_8bit);
extern int mos6502_instruction(vm_8bit); extern int mos6502_instruction(vm_8bit);
extern mos6502 *mos6502_create(vm_segment *, vm_segment *); extern mos6502 *mos6502_create(vm_segment *, vm_segment *);

View File

@ -404,6 +404,22 @@ mos6502_would_jump(int inst_code)
inst_code == RTI; inst_code == RTI;
} }
/*
* Return true if the given instruction _might_ write to memory, if used
* with an appropriate address mode (e.g. anything other than ACC).
*/
inline bool
mos6502_would_write_mem(int inst_code)
{
return
inst_code == ASL ||
inst_code == DEC ||
inst_code == INC ||
inst_code == LSR ||
inst_code == ROL ||
inst_code == ROR;
}
/* /*
* This is a _kind_ of factory method, except we're obviously not * This is a _kind_ of factory method, except we're obviously not
* instantiating an object. Given an address mode, we return the * instantiating an object. Given an address mode, we return the