summaryrefslogblamecommitdiffstats
path: root/src/emu/opc.h
blob: 8720958301041fa86f84b1577a82faad172367b2 (plain) (tree)
1
2
3
4
5
6
7
8
9








                        
                                                                              
          
                                                                              
               
                                                                             
                 
                                                                             
         
                                                                             
         
                                                                           








                    



                    
 







                    
 





                    

                       



                    



                    


                               
                          

                                          

      
#ifndef _OPC_H
#define _OPC_H

#include <stdint.h>

/* instructions formats:
 * ---------------------
 *
 *  arithmetic:
 *     |000|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|ccccccccccccc|0000000000000000000|
 *  logic:
 *     |001|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|ccccccccccccc|0000000000000000000|
 *  comparison:
 *     |010|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|00000000000000000000000000000000|
 *  load & store:
 *     |011|xxx|aaaaaaaaaaaaa|bbbbbbbbbbbbb|cccccccccccccccccccccccccccccccc|
 *  jump:
 *     |100|xxx|aaaaaaaaaaaaa|0000000000000|cccccccccccccccccccccccccccccccc|
 *  misc:
 *     |111|xxx|??????????????????????????????????????????????????????????|
 *
 */

/* arithmetic */
#define OPC_ADD  000
#define OPC_SUB  001
#define OPC_MUL  002
#define OPC_DIV  003
#define OPC_MOD  004

/* logic */
#define OPC_AND  010
#define OPC_OR   011

/* comparison */
#define OPC_CMP  020
#define OPC_EQ   021
#define OPC_NE   022
#define OPC_LT   023
#define OPC_LE   024
#define OPC_GE   025
#define OPC_GT   026

/* load & store */
#define OPC_MOV  030
#define OPC_LW   031
#define OPC_SW   032
#define OPC_PUSH 033
#define OPC_POP  034

/* jump instructions */
#define OPC_BEZ  040
#define OPC_JMP  041
#define OPC_CALL 042
#define OPC_RET  043

/* misc */
#define OPC_SYS  070

/* one instruction is 64 bit */
typedef uint64_t inst_t;

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

#endif