gmSCCodePatternClass
- Mark Juras
Owned by Mark Juras
The CodePattern Service Class
The service class CodePattern contains methods to provide a better notation for doing tests like the following within the tool code and to provide a facility for doing tests like this in gmSL.if(codptr[icode ] == OPC_LDA && codptr[icode+5 ] == OPC_LSB && codptr[icode+6 ] == LSB_List && codptr[icode+7 ] == OPC_MEM && codptr[icode+9 ] == OPC_LEV && codptr[icode+11] == OPC_LDA && codptr[icode+16] == OPC_LSB && codptr[icode+17] == LSB_ListIndex && codptr[icode+18] == OPC_MEM && codptr[icode+20] == OPC_ARG && codptr[icode+22] == OPC_INX)
<opcode id="OPC" opc="127" type="DoubleByte" role="none" subcodes="181" > <subcode id="NEW" value="0" /> <!-- Start new command --> <subcode id="LDA" value="1" /> <!-- Load a variable address --> ....
<opcode id="OPO" opc="178" type="DoubleByte" role="none" subcodes="5" > <subcode id="EndList" value="0" /> <subcode id="Argument" value="1" /> <subcode id="Lvalue" value="2" /> <subcode id="FindMatch" value="3" /> <subcode id="Comment" value="4" /> </opcode>
static UBYTE anaSetSelected[] = { OPC_OPC,OPC_LDA, OPC_LSB,LSB_List, OPC_OPC,OPC_MEM, OPC_OPC,OPC_LEV, OPC_OPC,OPC_LDA, OPC_LSB,LSB_ListIndex, OPC_OPC,OPC_MEM, OPC_OPC,OPC_ARG, OPC_OPC,OPC_INX, OPC_OPO,OPO_EndList };
The method CodePattern_FindOpcode
Prototypeint CodePattern_FindOpcode(char* ident);
Parameter | Description |
ident | Contains the opcode identifier in null-terminated string form. |
If there is an opcode with the indicated identifier, then its opc value is returned. If no such opcode exists, then a minus one is returned.
The method CodePattern_FindSubcode
Prototypeint CodePattern_FindSubcode(int opcode,char* label);
Parameter | Description |
opcode | Contains the sequence number of the desired opcode. This was the opc attribute of opcode when it was defined. |
label | Contains a null-terminated string specifying the label to be searched for. |
If found, the method returns the subcode value that was assigned. If not found, it returns a minus one.
The method CodePattern_Match
Prototypeint CodePattern_Match(UBYTE* pcode,int opadr,UBYTE* operation);
Parameter | Description |
pcode | Contains the code block being checked against the code pattern. |
opadr | Specifies the offset of the start of the actual operation codes in the code block. |
operation | contains the code pattern to be matched. |
If a match is made, then the method returns the offset of the first byte in the code block beyond the end of the match. If no match is made, the method returns zero.
The method CodePattern_Read
Prototypeint CodePattern_Read(char* source,UBYTE* operation);
Parameter | Description |
source | Contains the source representation of the code pattern in null-terminated form. |
operation | receives the code pattern itself in operation code form. |
If all goes well, the method returns the length of the compiled code pattern; else it returns one of the following negative error codes:
code | Meaning |
-1 | An unrecognized opcode operation (OPO subcode) was encountered. |
-2 | The subcode identifier associated with an opcode was not recognized. |
-3 | The closing square bracket ending a bracketed identifier was missing. |
-4 | A source code identifier was not found. |
Table of Contents