2024-01-09 15:56:54 -05:00
|
|
|
//
|
|
|
|
// Created by william on 1/9/24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef NESEMULATOR_DECODING_H
|
|
|
|
#define NESEMULATOR_DECODING_H
|
|
|
|
|
|
|
|
#include "../include/types.h"
|
|
|
|
#include "../include/system.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ADDR_MODE_ABSOLUTE, // a
|
|
|
|
ADDR_MODE_ABSOLUTE_INDEXED_X, // a,x
|
|
|
|
ADDR_MODE_ABSOLUTE_INDEXED_Y, // a,y
|
|
|
|
ADDR_MODE_ACCUMULATOR, // A
|
|
|
|
ADDR_MODE_IMMEDIATE, // #i
|
|
|
|
ADDR_MODE_IMPLICIT, // Imp
|
|
|
|
ADDR_MODE_INDIRECT_X, // (d,x)
|
|
|
|
ADDR_MODE_INDIRECT_JUMP, //
|
|
|
|
ADDR_MODE_INDIRECT_Y, // (d),y
|
|
|
|
ADDR_MODE_RELATIVE, // label
|
|
|
|
ADDR_MODE_ZERO_PAGE, // d
|
|
|
|
ADDR_MODE_ZERO_PAGE_INDEXED_X, // d,x
|
|
|
|
ADDR_MODE_ZERO_PAGE_INDEXED_Y, // d,y
|
|
|
|
} AddressingMode;
|
|
|
|
|
|
|
|
enum OperandType {
|
|
|
|
OPERAND_TYPE_ACCUMULATOR,
|
|
|
|
OPERAND_TYPE_IMMEDIATE,
|
|
|
|
OPERAND_TYPE_ADDRESS
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
word value;
|
|
|
|
enum OperandType type;
|
|
|
|
bool is_page_crossing;
|
|
|
|
} Operand;
|
|
|
|
|
2024-05-06 20:23:44 -04:00
|
|
|
address decode_operand_addr(AddressingMode addr_mode, bool *page_crossing);
|
2024-01-09 15:56:54 -05:00
|
|
|
|
2024-05-06 20:23:44 -04:00
|
|
|
Operand decode_operand(AddressingMode addr_mode);
|
2024-01-09 15:56:54 -05:00
|
|
|
|
2024-05-06 20:23:44 -04:00
|
|
|
byte read_operand(Operand operand);
|
2024-01-09 15:56:54 -05:00
|
|
|
|
|
|
|
char *get_addr_mode_name(AddressingMode addr_mode);
|
|
|
|
|
|
|
|
char *operand_name(Operand *operand);
|
|
|
|
|
|
|
|
char *get_op_code_name(byte op);
|
|
|
|
|
|
|
|
#endif //NESEMULATOR_DECODING_H
|