Advertisement

Fragging asm !

Started by September 02, 2000 04:16 PM
4 comments, last by Vlion 24 years, 3 months ago

#include 
short getTime()
{
    short retval;//short instead of char so the 
    _asm
    {	
        xor  ax,ax//zeros AX out
	int  1Ah/calls the clock interrupt
	mov  BYTE PTR retval,dl//copies DL(the millisecond) 
                               //value to retval
    }
    return retval;
}

void main()
{
    short temp1,temp2;
    for(int i=0;i++;i<=20)//for some reason it jumps to the end of the for...
    {
        temp1 = temp2 = GetTime();//inisialization
        while(temp1==temp2)
        {
            temp2 =  GetTime();
        }//this way when its displayed theres a different number everytime.
        cout << temp2 << ''\n'';
    }
}
 
I came, I saw, I got programmers block. ~V''lion
~V'lionBugle4d
Hi.

Should not the following statement:

for(int i=0;i++;i<=20)//for some reason it jumps to the end of the for...

read like this instead?:

for(int i=0;i<=20;i++)//for some reason it jumps to the end of the for...

Topgoro
We emphasize "gotoless" programming in this company, so constructs like "goto hell" are strictly forbidden.
Advertisement
This is simple C man. Exactly what the last poster said!

for(assignment, expression, assignment (usually increment/decrement) ) is the syntax.

=======================================
A man with no head is still a man.
A head with no man is plain freaky.
Above posts explain it all

Don''t wanna offend you, but are you still stuck with 16bit? Shame.

ROFL

Aaaaaah Late night programming errors, how I love them when I have found them !
-----------------------------Sancte Isidore ora pro nobis !
*claps hand to head*
Fool me !
One day....
I use shorts becasue they take up less memory.
I`m not super interested in the speed right now, else i`d use longs. *shrug*
~V''lion

I came, I saw, I got programmers block.
~V''lion
~V'lionBugle4d

This topic is closed to new replies.

Advertisement