forked from PlaneteCasio/Casio_asm
41 lines
978 B
C
41 lines
978 B
C
#include "opcodeInfo.h"
|
|
|
|
opcode_info_t* Opcode_opcodeList;
|
|
int pos;
|
|
|
|
int Opcode_init() {
|
|
Opcode_opcodeList=calloc(OPCODE_LIST_LEN, sizeof(opcode_info_t));
|
|
pos=0;
|
|
return Opcode_opcodeList!=0;
|
|
}
|
|
int Opcode_quit() {
|
|
free(Opcode_opcodeList);
|
|
return 1;
|
|
}
|
|
|
|
int Opcode_getOpByName(char* name, char type, opcode_info_t *op) {
|
|
for(int i=0; i<OPCODE_LIST_LEN; i++) {
|
|
*op=Opcode_opcodeList[i];
|
|
if(strcmpd(name, op->name)&&type==op->type) return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int Opcode_getOpByCode(unsigned char code, char type, opcode_info_t *op) {
|
|
for(int i=0; i<OPCODE_LIST_LEN; i++) {
|
|
*op=Opcode_opcodeList[i];
|
|
if(op->code==code&&type==op->type) return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void Opcode_register(unsigned char code, char* name, char type, char* desc) {
|
|
Opcode_opcodeList[pos].code=code;
|
|
Opcode_opcodeList[pos].type=type;
|
|
strcpyl(name, Opcode_opcodeList[pos].name, OPCODE_NAME_LEN);
|
|
#if defined(PC)
|
|
strcpyl(desc, Opcode_opcodeList[pos].desc, OPCODE_DESC_LEN);
|
|
#endif
|
|
pos++;
|
|
}
|