Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8501357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:11:26+00:00 2026-06-11T01:11:26+00:00

While examining the instruction set for Intel x86 processors I noticed there are ‘intuitive’

  • 0

While examining the instruction set for Intel x86 processors I noticed there are ‘intuitive’ instructions like ‘mov’, ‘add’, ‘mul’ … while others seem a bit unnatural like ‘sete’. The question is more out of curiosity rather than practical concerns: why would designers chose to implement particular execution scenarios in single instructions? Do you know any reading material that would explain such design decisions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:11:28+00:00Added an answer on June 11, 2026 at 1:11 am

    There are at least two possible sequences to achieve the code. Here’s my analysis of them

    ; "classic" code
     xor eax,eax     ; zero AL in case we don't write it.
     cmp edx,15
     jne past
      mov al,1        ; AL = (edx==15)
    past:
    

    And

    ; "evolved" code
    ; xor eax,eax optional to get a bool zero-extended to full register
    cmp edx,15
    sete al        ; AL = 0 or 1 according to edx==15
    

    It is a bit of a mindset that a conditional, simple assignment "should" involve a conditional jump on the opposite condition, even if it only jumps around a single instruction. But it is – in your own words – a particular execution scenario that occurs frequently so if a better alternative were available, why not?

    When code executes there are many factors affecting execution speed. Two of them are the time it takes for the result of a comparison/arithmetic/boolean operation to reach the flags register and the other the execution penalty when a jump is taken (I’m over-simplifying this a bit).

    So the classic code will either execute a move or take a jump. The former will probably be executed in parallel with other code and the latter may cause the prefetcher to load data from the new position resulting in wait states. The processor’s branch prediction may be involved and may – depending on a lot of factors – predict incorrectly which incurs additional penalties.

    In the evolved case, code prefetching is not affected at all which is good for execution speed. Also the sete sequence will probably fit in fewer bytes than the mov+jne combo which means that relatively less code cache line capacity/work will be involved in the execution which means there will be relatively more data cache capacity/work will be freed up as well. It the contents of the assignment isn’t needed right away the sete could be rescheduled to a position where it blends in better (execution-wise) with the surrounding code. This rescheduling could be performed explicitly (by the compiler) or implicitly (by the CPU itself). Static scheduling (by the compiler) is limited because most x86 integer instruction affect FLAGS so they can’t be separated far.

    For normal (usually un-tuned), bloated application code the use of instructions such as this will have little impact on overall performance. In highly specialized, hand tuned code with very tight loops the difference between executing within three rather than four or five cache lines could make an enormous difference, especially if multiple copies of the code are running on different cores.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been examining some PHP code today and I've noticed the usage of do-while
While refactoring my code base I found a piece of code which I'd like
While reading this class BitmapFactory I noticed that almost all methods inside are static.
I am working in C++ with VS2008 and Win7. While examining a program I
While importing data from a flat file, I noticed that some of lines have
I recently purchased a DRUPAL site and while examining the source code of index.php,
I inherited a project from a colleague that left the company. While examining his
While examining shader examples I recently found that it's pretty often to pass the
While debugging and keep pressing F5, if the source code does not exist, eclipse
While trying to build the mysql2 gem with ruby 1.9.2-p320 on Fedora 16, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.