-
Notifications
You must be signed in to change notification settings - Fork 5
/
opcodes.c
executable file
·64 lines (61 loc) · 2.16 KB
/
opcodes.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/***************************************************************************
* NESHLA: The Nintendo Entertainment System High Level Assembler
* Copyright (C) 2003,2004,2005 Brian Provinciano, http://www.bripro.com
*
* This program is free software.
* You may use this code for anything you wish.
* It comes with no warranty.
***************************************************************************/
/******************************************************************************/
#pragma hdrstop
#include "compiler.h"
/******************************************************************************/
#pragma package(smart_init)
/******************************************************************************/
U8 opRelSwap[] = {
opBPL_REL,opBMI_REL,
opBVC_REL,opBVS_REL,
opBCC_REL,opBCS_REL,
opBNE_REL,opBEQ_REL,
};
OPCODE *activeOpcode,*opcodeSta,*opcodeSty,*opcodeStx; // todo add opcode properties instead for check (ie. OP_STORE)
/******************************************************************************/
void OpcodesInit(char *label)
{
activeOpcode = NULL;
opcodeSta = &opcodes[IsOpcodeName("STA")];
opcodeSty = &opcodes[IsOpcodeName("STY")];
opcodeStx = &opcodes[IsOpcodeName("STX")];
}
/******************************************************************************/
int FASTCALL IsOpcodeName(char *label)
{
int i;
OPCODE *o=opcodes;
for(i=opTOTAL_UNIQUE-1;i>=0;i--)
if(!STRCMP((o++)->name,label))
return (opTOTAL_UNIQUE-1)-i;
return -1;
}
/******************************************************************************/
char * FASTCALL GetOpcodeName(int code)
{
int i,j;
OPCODE *o=opcodes;
for(i=opTOTAL_UNIQUE-1;i>=0;i--)
for(j=0;j<prtTOTAL;j++)
if((o++)->codes[j] == code)
return ((o-1))->name;
return "";
}
/******************************************************************************/
int FASTCALL RelSwapOp(int opcode)
{
int i;
for(i=7;i>=0;i--)
if(opRelSwap[i]==opcode) {
return opRelSwap[i^1];
}
return -1;
}
/******************************************************************************/