So I'm emulating an extra instruction in C for the MSP440 called IFcc, where cc is the condition. How it works is if the condition is true, then the 'true instructions' are executed, and the 'false instructions' are skipped, and vice versa if the condition is false. The instruction takes two arguments, TC which is the number of instructions to execute if condition is true, and FC which is the number on instructions to execute if the condition is false. Here is an example of what the assembly code might look like:
CMP &ALPHA,&BETA
IFEQ 2,2 ; Execute the first and second instructions if ALPHA = BETA
; or the third and fourth instructions if ALPHA BETA
MOV #0,&ALPHA ; Executed if ALPHA = BETA
MOV #1,&BETA ; Executed if ALPHA = BETA
MOV &BETA,&ALPHA ; Executed if ALPHA ≠ BETA
ADD #1,&ALPHA ; Executed if ALPHA ≠ BETA
What I'm having trouble figuring out, is how to ignore the instructions that should not be executed. The assembly itself wouldn't be changed to use branches, because the point of the IFcc instruction is to eliminate the necessity for branches. Any help with this would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire