OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 19, 2024 12:31 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Random NOP bytes in my binary
PostPosted: Thu Oct 28, 2021 4:32 pm 
Offline
Member
Member

Joined: Sat Oct 23, 2021 5:36 am
Posts: 26
My linker (or compiler?) generated strange NOP 9 byte sequences in my code between the functions...

66 0f 1f 84 00 00 00 nop word [rax+rax]
00 00 ---

Why does it put these in there? Alignment (address of the procedure after the bytes happens to be 16-aligned, so I'm guessing that can be the case)?

Is it related to the ICache maybe?

Thanks :D


Top
 Profile  
 
 Post subject: Re: Random NOP bytes in my binary
PostPosted: Thu Oct 28, 2021 5:14 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
It's for alignment. Most CPUs fetch instructions in 16-byte blocks, so aligning functions to 16-byte boundaries means the CPU can decode more instructions before it needs to fetch the next block.

Agner Fog's optimization guides explain it in more detail.


Top
 Profile  
 
 Post subject: Re: Random NOP bytes in my binary
PostPosted: Thu Oct 28, 2021 5:25 pm 
Offline
Member
Member

Joined: Sat Oct 23, 2021 5:36 am
Posts: 26
Octocontrabass wrote:
It's for alignment. Most CPUs fetch instructions in 16-byte blocks, so aligning functions to 16-byte boundaries means the CPU can decode more instructions before it needs to fetch the next block.

Agner Fog's optimization guides explain it in more detail.

Thanks! I thought it might be related to it, but I wasn't sure


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group