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 6948683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:51:18+00:00 2026-05-27T13:51:18+00:00

Under 64 bit x86 CPU normally we load number -1 in to register like:

  • 0

Under 64 bit x86 CPU normally we load number -1 in to register like:

mov     rdx, -1  //  48BAFFFFFFFFFFFFFFFF

… this instruction takes 10 bytes the way old versions of NASM assemble it.


Another way is:

xor     rdx, rdx //  4831D2        
dec     rdx      //  48FFCA  

       

… this opcode takes only 6 bytes.

EDIT:

As Jens Björnhager say (I have tested) xor edx, edx opcode should clear whole rdx register:

xor     edx, edx //  31D2        
dec     rdx      //  48FFCA 

… this opcode takes only 5 bytes.

EDIT:

Alexey Frunze found another solution:

mov     rdx, -1  // 48C7C2FFFFFFFF

… this instruction takes only 7 bytes.
But how to tell assembler to use shorter encoding (without using DB)? You can hint NASM to use this encoding, in case you’re using an old version which doesn’t default to enabling optimization (of code size), and you don’t use nasm -Ox manually.

mov     rdx, dword -1

What is faster and what is more economical?

  • 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-27T13:51:19+00:00Added an answer on May 27, 2026 at 1:51 pm

    There’s an alternative, 7-byte, encoding of mov rdx, -1: 48C7C2FFFFFFFF.

    You can try writing the instruction as mov rdx, dword -1 in the code to aid the compiler/assembler in using this shorter encoding.

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

Sidebar

Related Questions

I'm a bit confused about inheritance under sqlalchemy, to the point where I'm not
Under what circumstances would this or would this not be safe? I have a
I'm compiling Ruby 1.9.1-p376 under Ubuntu 8.04 server LTS (64-bit), by doing the following:
According to this MSDN page : WOW64 enables 32-bit applications to take advantage of
I have a project that runs perfectly well under windows 7, x86 installation. On
I have to start x64 bit application that is located under c:\windows\system32 (it is
A Windows 7 (64-bit) system runs the following code under Windows Azure Compute Emulator
A bit under a year ago, a teammember who has now left built an
In my Eclipse Indigo (64-bit) under Ubuntu, the SVNKit client doesn't show up in
The following code works as expected for me under 64-bits, but fails under 32-bit

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.