summaryrefslogblamecommitdiffstats
path: root/src/emu/opc.h
blob: 45d21a81439f7a2496f8841140b91c8daa16b015 (plain) (tree)



































































                                              
#ifndef _OPC_H
#define _OPC_H

#include <stdint.h>

/* instructions formats:
 * ---------------------
 *
 *  arithmetic:
 *     |000|xxx|aaaaa|bbbbb|ccccc|00000000000|
 *  logic:
 *     |001|xxx|aaaaa|bbbbb|ccccc|00000000000|
 *  load & store:
 *     |010|xxx|aaaaa|bbbbb|cccccccccccccccc|
 *  branch:
 *     |011|xxx|aaaaa|bbbbb|cccccccccccccccc|
 *  jump:
 *     |100|xxx|aaaaa|000000000000000000000|
 *  misc:
 *     |111|xxx|??????????????????????????|
 *
 */

/* arithmetic */
#define OPC_ADD  000
#define OPC_SUB  001
#define OPC_MUL  002
#define OPC_DIV  003
#define OPC_MOD  004
#define OPC_SHL  005
#define OPC_SHR  006

/* logic */
#define OPC_AND  010
#define OPC_OR   011
#define OPC_XOR  012
#define OPC_NOR  013

/* load & store */
#define OPC_MOV  020
#define OPC_LB   021
#define OPC_LH   022
#define OPC_LW   023
#define OPC_SB   024
#define OPC_SH   025
#define OPC_SW   026

/* branch instructions */
#define OPC_CMP  030
#define OPC_BEQ  031
#define OPC_BNE  032
#define OPC_BLT  033
#define OPC_BGE  034
#define OPC_BLE  035
#define OPC_BGT  036

/* jump instructions */
#define OPC_J    040
#define OPC_JAL  041

/* misc */
#define OPC_SYS  070

/* conversion functions */
uint32_t mnemonic2opc(const char *mnemonic);
const char *opc2mnemonic(uint32_t IR);

#endif