Implementing the Translation Function (Windows Embedded CE 6.0)
1/6/2010
The translation function translates p-codes to machine codes, and executes once for every generated function. The following code example shows the definition for the translation function.
typedef PFN_BltFunction (*PFN_PCodeToCpuCode)(int FnIndex, DWORD * pPCode, GenBltSignature * pBltSig, void * pBltFn);
To create a translation function that targets a specific microprocessor, use the p-code virtual machine and the existing i486 microprocessor and ARMV4 microprocessor translation functions as a starting point. The translation function returns a pointer to the first instruction of the machine code. The first machine code instruction does not have to be pMCode.
The p-code passed into the translation function must be valid. In addition, the first p-code instruction must be PCODE_OPCODE_SIG and the last instruction of the function to generate must be PCODE_OPCODE_EOF. These functions most likely correspond to machine code sequences for function entry and exit.
All conditional constructs, such as if_andi
, else
, and endif
, have a unique identifier embedded in the operation code that facilitates matching the if_andi
, else
, and endif
instructions. Looping constructs, such as loop
, break
, endloop
, also have a unique identifier. To retrieve the value of the identifier, use the GET_OPCODE_SIG macro after InstructionFetchAndDecode executes on the p-code instruction.
See Also
Concepts
Improving the Performance of Software Blits by Generating Blit Functions at Run Time
Implementing the GenBltCpuInitialize Function
Implementing the Optimization Function