ASMC
//*********************************ASMC BY HENRIK STOLPE ***********************************//// //*****A SMALL EXAMPLE SHOWING HOW ASSEMBLER CAN BE USED WITHIN C TO SPEED UP CALCULATIONS***//// //*****IN THIS THE ASSEMBLER LOOP PERFORMS TWICE AS FAST AS THE C EQUIVALENT ,WHEN USING*****//// //*****MANY LOOPS AND ADVANCED VARIABLE PASSINGS THE CPU TIME SAVING IS CONSIDERATE!!********//// //*****IF THIS WHOLE PROGRAM BEEN WRITTEN IN ASSEMBLER NOT USING <STDIO.H> AND "PRINTF()"IT**//// //*****WOULD BE A 100 TIMES FASTER!****//// //ANSI C// //USE _CDECL CALLING CONVENTION WHEN USING _ASM #include <stdio.h> int main(int num) { num=100000000; printf("Counting down 1000000000 to 1 using C language..\n"); printf("PRESS KEY TO START!\n"); getch(); printf("%d DONE!\n",ccount(num)); printf("Counting down 1000000000 to 1 using assembler language!!\n"); printf("PRESS KEY TO START!"); getch(); printf("%d DONE!\n",acount(num)); getch(); return(0); } int ccount(int c) { while(c>0) { c--; } return(c); } int acount(int a) { ///////80486 SPECIFIC ASSEMBLER OPCODES, COULD EASILY BE EXCHANGED FOR 680xx OPCODES __asm mov ecx, a; __asm lg:; __asm dec ecx; __asm loop lg ; __asm mov a,ecx; return(a); }