From: GAMMELJL AT SLU DOT EDU Date: Tue, 23 Dec 1997 21:05:19 -0600 (CST) Subject: Looping in assembly language To: djgpp AT delorie DOT com Message-id: <01IRIZPEXM9EBL3O7M@SLU.EDU> Organization: SAINT LOUIS UNIVERSITY St. Louis, MO MIME-version: 1.0 Precedence: bulk //In the gnu C/C++ interface of assembly and C/C++ how do I store //x[ecx] in the loop running from L1 to jne L1? //I would not need the input ("g" (i)) or the output ("=m" (x[i]) //and the line "for (i=1;i<11;i++) mode3();" could be just "mode3();". //Of course, the assembly line "cmp %1, %%ecx;" would become //"cmp $0x10, %%ecx;"--there is no problem with that. #include #define mode3() \ __asm__ ( \ "movl $0x0, %%ecx;" \ "L1: addl $0x1, %%ecx;" \ "movl %%ecx,%0;" \ "cmp %1, %%ecx;" \ "jne L1" \ : "=m" (x[i]) \ : "g" (i) \ : "ecx"); unsigned int x[20]; int i; int main() { for (i=1;i<11;i++) mode3(); //should be able to replace with mode3 for (i=0;i<11;i++) cout< //int i; //unsigned int x[20]; //void mode3(); //#pragma aux mode3 = \ // "mov ecx, 0", \ // "L1: add ecx, 4", \ // "mov x[ecx], ecx", \ // "cmp ecx, 40", \ // "jne L1" \ // modify [ EAX ECX EDX ]; //int main() { // mode3(); // for (i=0;i<11;i++) cout<