bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Very "slow" assembler


From: Andrej Hanin
Subject: Very "slow" assembler
Date: Tue, 13 Mar 2001 00:17:59 +0200

     Hello!!

  Firstly i apologize for my, may be, poor english, but i'll try to explain
the problem, i have encountered using inline assembler code in my C program.

       Just info about system and softaware versions:

      PC   -  Intel PentiumMMX 200,   96RAM
      OS   -   Microsoft Win 98
      GNU Assembler version is 2.8.1
      GCC compiler version is 2.952

      ========>Problem<===========
     I have discovered, that VERY simple inline assembler code in C program,
and assembler code written in the another assembler compiler (Borland Turbo
Assembler v3.1) they have VERY BIG difference in execution times. It means,
i
have
(it just for example) 2 asm cycles embedded one in another with the
following structure

       for(i=0; i<1000; i++)
              for(j=0; j<1000000; j++)
                  {instructions}
So, as you can see these instructions will be executed 1000*1000000 = 10^9
times

This is my C with inline assembler code:

int main()
{

asm(  "
                movw $1000 , %bx
        1:      movl $1000000 , %ecx
        0:      addb %al , %ah  // just any instruction
                loop 0b
                decw %bx
                jnz 1b
       "
   );
}

CAN YOU IMAGINE the execution time of this code?????????
    just   25 seconds !!!!!!!!!!!!!!

But THE SAME code written and compiled with TASM:
This is the code


MASM
MODEL small
.code
.486
MAIN:

         mov bx  , 03E8h
B:      mov ecx , 0F4240h
A:      add al , bh  ;just any instruction
         loop A
         dec bx
         jnz B

mov ax,4c00h ;
int 21h ; exit to system
end main ;

This code executes LESS THEN IN 1 SECOND!!!!!!   In       ONE    second  in
comparsion to 25 seconds from the first C code!!!!!!
        I'm sure this is not a bug, just my stupidity, but PLEASE help
me!!!! I can't understand what's the matter!!!

   Thank you!!!!

         Andrej Hanin











reply via email to

[Prev in Thread] Current Thread [Next in Thread]