assembly


boolean evaluation c++ asm code


I am currently testing various codelines to enrich my knowledge in Assembly (X86, specifically now) and using MS VC++.
I am clueless regarding how the machine generates different parts of the code compared to other compilers (gcc)
I've come across a boolean evalution line, which resulted in the following ASM code:
void boolean_literals() {
/*true/false*/
01133A2E C6 45 FB 01 mov byte ptr [b],1
bool b = 6 == 6;
01133A32 0F B6 45 FB movzx eax,byte ptr [b]
01133A36 85 C0 test eax,eax
01133A38 74 04 je boolean_literals+2Eh (01133A3Eh)
if (b) {
01133A3A C6 45 FB 00 mov byte ptr [b],0
b = false;
}
The thing is - I can't actually see the boolean evaluation in ASM:
mov byte ptr [b],1
Any compilers option that might solve this or w/e ?
:)
The boolean evaluation is here:
test eax,eax
je boolean_literals+2Eh (01133A3Eh)
Test performs: flags = eax and eax which will set ZF=1 if eax == 0.
The je will jump on ZF=1 thereby completing the boolean test.
If you enable optimizations, the compiler will most likely :-) find that the result of your test is always true, and will thus dispense with the test altogether. In which case the following code is all that is needed.
mov byte ptr [b],1 //b = true

Related Links

Why is gcc generating an extra return address?
What is the joke behind “goto $”?
Did I change the given (very short) assembler instruction correctly? [duplicate]
Why do I only need to increment for change a asm instruction using hexa editor
Simple testable PIC16F1703 code?
Printing the Alphabet in Assembly
How can I save an array to a specific memory location?
AArch64 relocation prefixes
How to Sum Two Hex Numbers in Assembly
ARM assembly if(data & 0x01) rGPGDAT &= ~(0x1<<7);
Confirmation dialog in MIPS assembly
Why does ARM say that “A link register supports fast leaf function calls”
INT 10h/ah=13h doesn't print strings when part of second stage bootloader
Where exactly is the red zone on x86-64?
Int 10H not working in QEMU
How create an Little Mans Computer (LMC) code that will get a number. Display 1 if the number is odd, display 0 if the number is even

Categories

HOME
batch-file
apache-spark-mllib
spring-data-redis
gradient
owl-carousel
newrelic
parameters
limit
mvc5
jtextpane
augeas
ibeacon-android
startup
flatpak
package.json
symfony-2.8
video-editing
symfony-console
production
solrcloud
ag
parcelable
xcode-ui-testing
asymptotic-complexity
intersystems-cache
dotspatial
panoramas
left-join
instantiation
engine.io
apic
dm-script
cd
ods
xv6
escpos
softmax
naming
drupal-theming
linter
dotnet-httpclient
configurationmanager
mongotemplate
trojan
cup
d3-force-directed
gameplay-kit
branch-prediction
autosar
flex-monkey
hadoop-2.7.2
jquery-jscrollpane
scaffolding
android-dateutils
hadoop-partitioning
nupic
piracy-prevention
asyncdisplaykit
boomerang
avisynth
dllimport
evolus-pencil
sony-lifelog-api
dronekit-android
ansi
snackbar
node-serialport
procedural-programming
variadic-templates
sql-scripts
linkedin-jsapi
create.js
angular-carousel
ss7
gnumeric
android-framework
syndicationfeed
scriptaculous
solace-mq
cffile
dolby-audio-api
octal
video-codecs
server-administration
nokia-s40
correlated-subquery
mapping-by-code
landscape-portrait
umra
svk
metaweblog
updatesourcetrigger
object-database
binomial-heap
ajax-polling
sifr
spread
lemmatization

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App