flat assembler
Message board for the users of flat assembler.

Index > Main > question about operators and logical operations

Author
Thread Post new topic Reply to topic
dev_89



Joined: 24 Feb 2013
Posts: 8
dev_89 12 Apr 2013, 06:03
now i know how the operators works but i don't know and can't understand how they does the calculation and sets the flags.
i mean i know that:
AND
true true = true
true false= false
false true= false
false false = false

OR
true true = true
true false= true
false true= true
false false = false

but i just can't understand when for example in AND operator both arguments are true how the calculation is done and then flags are set?
for example eax is 1.now if we AND eax with 18 result is zero.i'm interested why and how result becomes zero in here?or for example OR operator.if we OR eax with 18 result becomes 19?!
in overall i wanna know how AND,OR operators does the calculation and sets the flags?
help would be greatly appreciated.
Post 12 Apr 2013, 06:03
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 12 Apr 2013, 06:20
dev_89,

Those instructions are bitwise, i.e. they are performed on each pair of corresponding bits of operands.

Flags are set according to specification (Intel SDM or AMD APM), though some of them can be deduced using common sense: ZF is set iff result is zero, SF is equal to highest bit of result, PF is set iff number of ones in least-significant byte of result is even.
Post 12 Apr 2013, 06:20
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4016
Location: vpcmpistri
bitRAKE 12 Apr 2013, 08:41
Helps to know how to work in binary and hexadecimal:

18 = 10010b
01 = 00001b
____________
00 = 00000b

...here we can easily see no bits line up, vertically. So, AND acts like a filter, and if we had a large column of numbers in binary it would be easy to see the result.

..and here is a condition flag tool, by Svin.


Description: Here are some tools created by Svin to practice binary skills: Good for kids of all ages!
Download
Filename: Svin.math.zip
Filesize: 41.74 KB
Downloaded: 411 Time(s)


_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 12 Apr 2013, 08:41
View user's profile Send private message Visit poster's website Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 13 Apr 2013, 06:50
This should be in Main or (not yet created) "General programming" subforum
Post 13 Apr 2013, 06:50
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 13 Apr 2013, 11:51
DOS386,

This should be in Heap, as it's not directly related to assembly programming. Wink
Post 13 Apr 2013, 11:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20292
Location: In your JS exploiting you and your system
revolution 13 Apr 2013, 17:01
I think it is related to assembly programming. We deal with bits and logical operators all the time.
Post 13 Apr 2013, 17:01
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.