|
fleurly,给你出个题目做做,有兴趣的话
#include
#include
#define A(R) (R++)
#define S(R) ( (R>0)?(R--) 0) )
#define STOP {printf("R3=%u\n", R3);return 0;}
#define E(val, C) { if(val){goto C;}}
#define DEBUG() {printf("R1=%u, R2=%u, R3=%u, R4=%u, R5=%u, R6=%u, R7=%u, R8=%u, R9=%u, R10=%u \n", R1, R2, R3, R4, R5, R6, R7, R8, R9, R10);}
#define R6_SRC 6
#define R7_SRC 7
unsigned int R1=R6_SRC;
unsigned int R2=R7_SRC;
unsigned int R3=0;
unsigned int R4=0;
unsigned int R5=0;
unsigned int R6=0;
unsigned int R7=0;
unsigned int R8=0;
unsigned int R9=0;
unsigned int R10=0;
void testA(){
printf("R1=%u\n", R1);
A(R1);
printf("R1=%u\n", R1);
}
void testS(){
R1=1;
printf("R1=%u\n", R1);
S(R1);
printf("R1=%u\n", R1);
S(R1);
printf("R1=%u\n", R1);
}
void testMain(){
R1=R6_SRC;
R2=R7_SRC;
DEBUG();
S(R2);
L_1:
A(R4);
A(R5);
A(R6);
A(R7);
//A(R8);
A(R9);
S(R1);
E(R1, L_1);
//R3 = R3 + R4
L_ONE_ROUND:
printf("-------- Begin of One round ---------\n");
DEBUG();
A(R5);
L_R3_MUL:
S(R5);
E(R5, L_R3_ADD);
E(R2, L_END_R3_MUL);
L_R3_ADD:
//sleep(1);
//DEBUG();
A(R3);
S(R4);
E(R4, L_R3_ADD);
E(R7, L_COPY_R7_R4);
E(R8, L_COPY_R8_R4);
//Copy R7 to R4
L_COPY_R7_R4:
A(R8);
A(R4);
S(R7);
E(R7, L_COPY_R7_R4);
E(R4, L_R3_MUL);
L_COPY_R8_R4:
A(R7);
A(R4);
S(R8);
E(R8,L_COPY_R8_R4);
E(R4, L_R3_MUL);
L_END_R3_MUL:
//Decide which one to use to copy to R5
//sleep(1);
//DEBUG();
E(R9, L_COPY_R9_R5);
E(R10, L_COPY_R10_R5);
L_COPY_R9_R5:
A(R10);
A(R5);
S(R9);
E(R9, L_COPY_R9_R5);
E(R5, L_COPY_R3_TO_R6);
L_COPY_R10_R5:
A(R9);
A(R5);
S(R10);
E(R10,L_COPY_R10_R5);
E(R5, L_COPY_R3_TO_R6);
L_COPY_R3_TO_R6:
R4_CLEAR:
S(R4);
E(R4, R4_CLEAR);
R7_CLEAR:
S(R7);
E(R7, R7_CLEAR);
R8_CLEAR:
S(R8);
E(R8, R8_CLEAR);
L_COPY_R3_TO_R7_START:
A(R7);
A(R4);
S(R3);
E(R3, L_COPY_R3_TO_R7_START);
S(R2);
E(R2, L_ONE_ROUND);
L_END_PRO:
DEBUG();
return ;
}
int main(){
testMain();
return 0;
}
|
|