KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am new to x86 assembly language, I have a signed integer saved in register eax , and I want to check if the number is negative or positive. To do that, I used bt instruction to check the first bit. Here is what I did: bt eax,0 jnc isNegative bt loads the first bit to carry flag, and I used jnc to check if carry flag is 0 or 1. If it's 1, it should be a negative number, and does negative instructions... however, the output is unpredictable, sometimes I have a positive and it recognize it as a negative number. Am I doing something wrong? EDIT: I just realized it could have something to do with bit numbering. It is actually checking the least significant bit instead of the first bit. Let me try using bt eax, 31
Tags (comma-separated)
Save Edits
Cancel