IFs in a CPU?

.NET Framework/non-language specific Discuss, IFs in a CPU? at Programmers Lounge forum; Ths has bothered me for a while, how does a CPU make a decision? It's essentially pumping a string of ...


Go Back   Gamerz Needs - For All Your Gaming Needs! > Technology Zone > Programmers Lounge > .NET Framework/non-language specific
Forgot Password? | Sign Up!

Notices

Advertisement
   

Reply
 
Bookmark this Thread Tools Display Modes
  #1  
Old 08-03-2008, 05:18 AM
RobotGymnast's Avatar
Gold Double Sided Axe+
 
Last Online: Yesterday 07:19 PM
Join Date: Oct 2006
Location: As far away from you as possible
Posts: 276
Donation Award 
Thanks: 20
Thanked 42 Times in 23 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 5
RobotGymnast is on a distinguished road
Points: 3,422.27
Bank: 0.00
Total Points: 3,422.27
Send a message via MSN to RobotGymnast
IFs in a CPU?

Ths has bothered me for a while, how does a CPU make a decision? It's essentially pumping a string of electrons, so how does that work on an IF statement? My only thinking could be you evaluate the condition, multiply the result by 64 or something, and then jump to [current address+(condition*0x40)], because then it would jump ahead 64 on TRUE, and jump ahead 0 on FALSE.. but that doesn't sound right. Oh and yes, this is an ASM representation vs a CPU representation.

How does a computer evaluate a conditional?
__________________
Programmer in C++ and webpage stuff.. some C# and Java applets, and some DirectX & OpenGL.

My display pic is from http://www.homestarrunner.com
  #2  
Old 09-24-2008, 11:20 AM
X-Staff
 
Last Online: 11-16-2008 03:35 AM
Join Date: Jun 2006
Location: England
Posts: 4,729
Blog Entries: 10
Thanks: 185
Thanked 1,186 Times in 638 Posts
Nominated 2 Times in 1 Post
TOTW/F/M Award(s): 0
Latest Blog: Exam Results
Rep Power: 23
Slugsnack has a spectacular aura aboutSlugsnack has a spectacular aura aboutSlugsnack has a spectacular aura about
Points: 937.30
Bank: 161,489.27
Total Points: 162,426.57
You need to stay healthy. :D - Kyle Marked as kashin's property. - kashin snack for slugs and worms - Ken Cheers! Youve finally got your dick to go past 1 inch. Rofl jk sluggy =P - choad Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS! - choad 
Gold - GodChaos Green - Slugsnack Gray - Slugsnack Gold - Slugsnack Lavender - Purple_Haze 
Dark Blue - Slugsnack Burgundy - Slugsnack Brown - Slugsnack Black - Slugsnack 
Old thread but has no reply yet..

A computer evaluates conditions essentially by comparing and if equal, it sets a flag in the EFLAGs register named the zero flag. There are then JMPs that are conditional on the state of various flags.

So in an IF statement, the condition is evaluated and the code execution jumps conditionally as a result of the comparison.

Is that what you wanted to know ?
__________________
  #3  
Old 09-24-2008, 12:31 PM
RobotGymnast's Avatar
Gold Double Sided Axe+
 
Last Online: Yesterday 07:19 PM
Join Date: Oct 2006
Location: As far away from you as possible
Posts: 276
Thanks: 20
Thanked 42 Times in 23 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 5
RobotGymnast is on a distinguished road
Points: 3,422.27
Bank: 0.00
Total Points: 3,422.27
Send a message via MSN to RobotGymnast
yes it is, but since then I've figured it out.. I was actually looking for a much lower-level explanation though. I understand conditional jumps, but what I wanted to know was how it evaluates the condition. Either way, it's all just boolean logic (greater than, less than, greater than or equal, etc.).. they can all be evaluated with the right boolean function. I understand it. Thanks though
__________________
Programmer in C++ and webpage stuff.. some C# and Java applets, and some DirectX & OpenGL.

My display pic is from http://www.homestarrunner.com
  #4  
Old 09-25-2008, 02:12 AM
X-Staff
 
Last Online: 11-16-2008 03:35 AM
Join Date: Jun 2006
Location: England
Posts: 4,729
Blog Entries: 10
Thanks: 185
Thanked 1,186 Times in 638 Posts
Nominated 2 Times in 1 Post
TOTW/F/M Award(s): 0
Latest Blog: Exam Results
Rep Power: 23
Slugsnack has a spectacular aura aboutSlugsnack has a spectacular aura aboutSlugsnack has a spectacular aura about
Points: 937.30
Bank: 161,489.27
Total Points: 162,426.57
You need to stay healthy. :D - Kyle Marked as kashin's property. - kashin snack for slugs and worms - Ken Cheers! Youve finally got your dick to go past 1 inch. Rofl jk sluggy =P - choad Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS!!! Give Me Some SNACKS! - choad 
Gold - GodChaos Green - Slugsnack Gray - Slugsnack Gold - Slugsnack Lavender - Purple_Haze 
Dark Blue - Slugsnack Burgundy - Slugsnack Brown - Slugsnack Black - Slugsnack 
At a hardware level, it's just logic gates. For example, to compare a 1 and a 0 state, they could put it through a OR gate and if the result is one then that could clear the zero flag. I am speculating about the exact gate they use but OR would certainly work for comparing 1 and 0.
__________________
  #5  
Old 09-25-2008, 03:52 AM
RobotGymnast's Avatar
Gold Double Sided Axe+
 
Last Online: Yesterday 07:19 PM
Join Date: Oct 2006
Location: As far away from you as possible
Posts: 276
Thanks: 20
Thanked 42 Times in 23 Posts
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Latest Blog:
Rep Power: 5
RobotGymnast is on a distinguished road
Points: 3,422.27
Bank: 0.00
Total Points: 3,422.27
Send a message via MSN to RobotGymnast
yeah I know. again, I figured it out. For those still wondering, reading the Art of Assembly really helps. Thanks though
__________________
Programmer in C++ and webpage stuff.. some C# and Java applets, and some DirectX & OpenGL.

My display pic is from http://www.homestarrunner.com
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Advertisement
   


Main Navigation
Home
GzN Forums
GzN Games
GzN News
Top Games
GzN Cheats
GzN Articles
GzN Reviews
GzN Downloads
User Control Panel
Advertising
RSS Feed
2Moons
Adventure Quest
AirRivals
America's Army
Anarchy Online
Archlord
Audition
Battlefield Series
Cabal Online
Call Of Duty Series
Combat Arms
Conquer Online
Counter Strike
Day of Defeat
Deicide Online
Diablo Series
Doom Series
Drift City
Enemy Territory
Eudemons Online
Final Fantasy
Flyff (Fly For Fun)
General Game Discussion
Ghost Online
Granado Espada
Grand Theft Auto Series
Guild Wars
Gunbound
Gunz Online
Habbo Hotel
Half-Life 2
Hero Online
KartRider
Knights Online
Maple Story
Medal of Honor
MU Online
Neopets
Pangya
Quake Series
Ragnarok Online
Rappelz
Rakion
Red Orchestra
Rose Online
Runescape
Scions of Fate
Silkroad Online
Sims Series
Soldier Front
Starcraft
Tales of Pirates
Tibia
The Ship
Trickster Online
TS Online
Unreal Tournament
War Rock
WolfTeam
World of Warcraft & Series
Affiliates
COD4 Hacks
BF2 Hacks


All times are GMT -8. The time now is 01:32 AM.