flat assembler
Message board for the users of flat assembler.

Index > Windows > DDRAW example bltfast arguments question

Author
Thread Post new topic Reply to topic
Sephiroth



Joined: 25 Sep 2005
Posts: 2
Location: Switzerland
Sephiroth
Hi,

I'm a newbie in asm & windows-programming and I'm analyzing the ddraw example to learn something about it.

But I discovered something I don't understand:

Code:
comcall DDSBack,BltFast,0,0,[DDSPicture],rect,DDBLTFAST_SRCCOLORKEY    

This generates:
Code:
...
PUSH_imm8 0x1
PUSH_imm32 0x4498cb
PUSH RM 0x4020c8
PUSH_imm8 0x0
PUSH_imm8 0x0
MOV EAX, [0x4020c4]
PUSH EAX 
MOV EAX, [ EAX ]
...
    

before calling the bltfast...

In a later execution
Code:
comcall DDSBack,BltFast,288,200[DDSPicture],rect,DDBLTFAST_SRCCOLORKEY    


which generates:

Code:
PUSH_imm8 0x1
PUSH_imm32 0x4498cb
PUSH RM 0x4020c8
PUSH_imm32 0xc8
PUSH_imm32 0x120
MOV EAX, [0x4020c4]
PUSH EAX
    


The API itself is defined as:
Code:
HRESULT BltFast(
  DWORD dwX,                            
  DWORD dwY,                            
  LPDIRECTDRAWSURFACE7 lpDDSrcSurface,  
  LPRECT lpSrcRect,                     
  DWORD dwTrans                         
);
    


So... my question is:
Why is it ok to give PUSH imm8 to the dwX & dwY in the first call and later PUSH imm32 ?
Why doesn't fasm generate imm32 pushes in the first place ?
How does windows decide to use the unspecified(?) "imm8" version of bltfast instead of the "imm32" version ?
Where did I miss something ? (I discovered that the only relevant differences could be in the EBX & EDX registers but I can't figure out what)

Could someone of you Assembler-Gods or Demi-Gods help me ?

Thanks,
Sephiroth

PS: I'm using the fasmw151 example of DDRAW but discovered the same thing in the latest release too.
Post 25 Sep 2005, 09:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
maybe "push imm8" extends imm8 constant to 32bits and then pushes it? Wink
Post 25 Sep 2005, 12:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
most likely
Post 25 Sep 2005, 12:45
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Sephiroth



Joined: 25 Sep 2005
Posts: 2
Location: Switzerland
Sephiroth
Thanks a lot, you Gods and Demi-Gods out there ! You're great !

I read your replies and checked the intel documentation again...
Code:
0x6a  PUSH imm8     

...is under:
Code:
PUSH - Push Word or Doubleword Onto the Stack    


Ta-da !

Next time I'll check the Intel Docs before posting such a message !

Thanks,
Sephiroth
Post 25 Sep 2005, 13:37
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend
6Ah xxh pushes values in range -127 till 128 (00h-FFh). Other values must be pushed with 68h xxh xxh xxh xxh
Post 25 Sep 2005, 19:04
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.