flat assembler
Message board for the users of flat assembler.

Index > Main > test bit always returns true - solved

Author
Thread Post new topic Reply to topic
aq83326



Joined: 25 Jun 2011
Posts: 21
aq83326
Figured it out, I put "uses eax" when using stdcall, but as we (I) should know, "uses" get restored but eax is where the return value is located.

Code:
proc testBit stdcall uses eax ebx,input,position
     mov ebx, [position]
     mov eax, 0
     bt [input],ebx
     setc al
     ret
endp    

Code:
proc testBit stdcall uses eax ebx,input,position
     mov ebx, [position]
     mov eax, [input]
     bt eax,ebx
     mov eax,0
     setc al
     ret
endp    

Both of the above always return true.
Post 03 May 2012, 18:51
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17331
Location: In your JS exploiting you and your system
revolution
aq83326 wrote:
Figured it out, I put "uses eax" when using stdcall, but as we (I) should know, "uses" get restored but eax is where the return value is located.

Code:
proc testBit stdcall uses eax ebx,input,position
     mov ebx, [position]
     mov eax, 0
     bt [input],ebx
     setc al
     ret
endp    

Code:
proc testBit stdcall uses eax ebx,input,position
     mov ebx, [position]
     mov eax, [input]
     bt eax,ebx
     mov eax,0
     setc al
     ret
endp    

Both of the above always return true.
Actually, both of the above always return eax untouched back to the caller. If the caller sets eax=0 then they both return false.
Post 03 May 2012, 22:43
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. Also on YouTube, Twitter.

Website powered by rwasa.