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

Assembly language coding help required
How to boot in vmware?
Assembly runtime memory allocation
Determining the output of the following assembly codes [closed]
How to check if a signed integer is neg or pos?
what am i doing wrong/ trying to run MIPS program to construct/draw a boxe
Question regarding assembly language
What address does the x86 begin executing at?
Simple MakeFile Problem
How to solve this logic operation? (homework)
how can i do a snake game on tasm program with assembly language? [duplicate]
Query regarding binary numbers
Does ret instruction cause esp register added by 4?
What segment is used by default in x86 indirect addressing?
Factorial
Converting Decimal to Binary and Printing in MIPS

Categories

HOME
uml
google-app-engine
gdb
battery
composite-primary-key
package
gradient
r-googlesheets
nsbundle
switch-statement
permissions
cq5
regular-language
babeljs
jetty
nuget-package
frontend
trac
opengl-3
flume
jquery-ui-sortable
github-enterprise
mod-security
azure-iot-hub
dynamic-sql
feathersjs
jersey-1.0
windows-xp
squashfs
backpack-for-laravel
zxing
outliers
android-maps
genexus-sd
inversion-of-control
ceylon
gp
volatile
mockjax
kodi
hreflang
hunspell
hivemq
docfx
escpos
smoothstate.js
jide
dynamic-linq
lampp
proget
reportservice2010
stdmap
wpas
subnet
backbone-collections
android-testing
oozie-coordinator
rackspace-cloud
flyout
flac
angular2-testing
winusb
preprocessor
jboss-tools
ng-grid
mediametadataretriever
nss
ellucian-scribe
phpgrid
qt5.2
themoviedb-api
viola-jones
snoop
theos
cbind
jama
rcaller
jjaql
radiant
scriptaculous
ie8-compatibility-mode
code-duplication
mbunit
beaker-testing
asdf
flex++
octal
composite-component
sqlclr
fragmenttransaction
faye
garbage
mapping-by-code
fsevents
entitydatasource
tmx
message-passing
filesystemobject
data-mapping
purepdf
visualj#
sun
complex-event-processing
sifr3
fdf
contentpresenter
pbcopy

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