flat assembler
Message board for the users of flat assembler.

 Index > Main > question about operators and logical operations
Author
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.
12 Apr 2013, 06:03
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.
12 Apr 2013, 06:20
bitRAKE

Joined: 21 Jul 2003
Posts: 3989
Location: vpcmipstrm
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: 396 Time(s)

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
12 Apr 2013, 08:41
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
13 Apr 2013, 06:50
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.
13 Apr 2013, 11:51
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 20247
revolution 13 Apr 2013, 17:01
I think it is related to assembly programming. We deal with bits and logical operators all the time.
13 Apr 2013, 17:01
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum