flat assembler
Message board for the users of flat assembler.

Index > Windows > trouble converting C to ASM

Author
Thread Post new topic Reply to topic
pinny_woman



Joined: 29 Mar 2008
Posts: 9
pinny_woman 30 Mar 2008, 17:05
Hi,

I've been trying to convert an app written in C to assembly. I've managed well so far with the conversion but have come unstuck with the following:

there's a procedure declared thus:
Code:
HBITMAP CreateMask(HBITMAP hColor, COLORREF crTrans)
    

which I converted to:
Code:
proc CreateMask, hColor, crTrans
.
.
endp
    


The problem I'm having is how to pass the params.
The C code is:
Code:
gMask = CreateMask(gImg, RGB(0, 0, 0));
    


How do I convert the RGB(0,0,0) to pass in asm?

Thanks for your time Wink
Post 30 Mar 2008, 17:05
View user's profile Send private message Reply with quote
DJ Mauretto



Joined: 14 Mar 2007
Posts: 464
Location: Rome,Italy
DJ Mauretto 30 Mar 2008, 18:13
Code:
      push    0              ; RGB = 0,0,0  Question  
 push    gImg 
       call    CreateMask


If you Have RGB struct in bytes 

  movzx   eax,byte [Red] 
     shl     eax,16 
     movzx   ebx,byte [Green]  
  shl     ebx,8 
      or      eax,ebx 
    movzx   ecx,byte [Blu] 
     or      eax,ecx 
    push    eax                  ; EAX = 0x00RRGGBB
     push    gImg 
       call    CreateMask
    
Post 30 Mar 2008, 18:13
View user's profile Send private message Reply with quote
itsnobody



Joined: 01 Feb 2008
Posts: 93
Location: Silver Spring, MD
itsnobody 30 Mar 2008, 18:34
Just use 0x00RRGGBB instead of the RGB macro
Post 30 Mar 2008, 18:34
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4334
Location: Now
edfed 30 Mar 2008, 20:20
Code:
movzx eax,[green]
mov ah,[red]
shl eax,8
mov al,[blue]
push eax
push gimg
call createmask
    

7 lines instead of 10.

are rgb encoded on bytes or dwords?
cause C convention is to pass params by the stack.
then, you build some equates to access them via the esp or ebp pointer.
Post 30 Mar 2008, 20:20
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.