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

  • Home
  • SEARCH
  • 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 3932740
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:31:24+00:00 2026-05-19T23:31:24+00:00

I am working through Kip Irvine’s "Assembly Language for x86 Processors, sixth edition" and

  • 0

I am working through Kip Irvine’s "Assembly Language for x86 Processors, sixth edition" and am really enjoying it.

I have just read about the NOP mnemonic in the following paragraph:

It [NOP] is sometimes used by compilers and assemblers to align code to
even-address boundaries."

The example given is:

00000000   66 8B C3   mov ax, bx
00000003   90         nop
00000004   8B D1      mov edx, ecx

The book then states:

x86 processors are designed to load code and data more quickly from even
doubleword addresses."

My question is: Is the reason this is so is because for the x86 processors the book refers to (32 bit), the word size of the CPU is 32 bits and therefore it can pull the instructions with the NOP in and process them in one go ? If this is the case, I am assuming that a 64 bit processor with a word size of a quadword would do this with a hypothetical 5 bytes of code plus a nop ?

Lastly, after I write my code, should I go through and correct alignment with NOP’s to optimize it, or will the compiler (MASM, in my case), do this for me, as the text seems to imply ?

  • 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-05-19T23:31:25+00:00Added an answer on May 19, 2026 at 11:31 pm

    Code that’s executed on word (for 8086) or DWORD (80386 and later) boundaries executes faster because the processor fetches whole (D)words. So if your instructions aren’t aligned then there is a stall when loading.

    However, you can’t dword-align every instruction. Well, I guess you could, but then you’d be wasting space and the processor would have to execute the NOP instructions, which would kill any performance benefit of aligning the instructions.

    In practice, aligning code on dword (or whatever) boundaries only helps when the instruction is the target of a branching instruction, and compilers typically will align the first instruction of a function, but won’t align branch targets that can also be reached by fall through. For example:

    MyFunction:
        cmp ax, bx
        jnz NotEqual
        ; ... some code here
    NotEqual:
        ; ... more stuff here
    

    A compiler that generates this code will typically align MyFunction because it is a branch target (reached by call), but it won’t align the NotEqual because doing so would insert NOP instructions that would have to be executed when falling through. That increases code size and makes the fall-through case slower.

    I would suggest that if you’re just learning assembly language, that you don’t worry about things like this that will most often give you marginal performance gains. Just write your code to make things work. After they work, you can profile them and, if you think it’s necessary after looking at the profile data, align your functions.

    The assembler typically won’t do it for you automatically.

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

Sidebar

Related Questions

I've been working through Bjarne Stroustrup's The C++ Programming Language (2nd edition - I
I'm working through Practical Web 2.0 Appications currently and have hit a bit of
I am working through some of the exercises in The C++ Programming Language by
I am working through a REST services book dealing with WCF. I have been
I am working through the Ruby-on-Rails3 Tutorial Chapter 8. I have created a form
Working through the summer of nHibernate tutorials have gotten to the section on queries.
I am working through an MVVM tutorial, and I have the following code, written
When working through MathLink with slave kernel I have a problem with correct parsing
Working through Agile Web Development with Rails edition 4 and hit the section on
I've been working through the book Scripted GUI Testing with Ruby, and I'm really

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.