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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:44:21+00:00 2026-05-23T15:44:21+00:00

I understand in x86_64 assembly there is for example the (64 bit) rax register,

  • 0

I understand in x86_64 assembly there is for example the (64 bit) rax register, but it can also be accessed as a 32 bit register, eax, 16 bit, ax, and 8 bit, al. In what situation would I not just use the full 64 bits, and why, what advantage would there be?

As an example, with this simple hello world program:

section .data
msg: db "Hello World!", 0x0a, 0x00
len: equ $-msg

section .text
global start

start:
mov rax, 0x2000004      ; System call write = 4
mov rdi, 1              ; Write to standard out = 1
mov rsi, msg            ; The address of hello_world string
mov rdx, len            ; The size to write
syscall                 ; Invoke the kernel
mov rax, 0x2000001      ; System call number for exit = 1
mov rdi, 0              ; Exit success = 0
syscall                 ; Invoke the kernel

rdi and rdx, at least, only need 8 bits and not 64, right? But if I change them to dil and dl, respectively (their lower 8-bit equivalents), the program assembles and links but doesn’t output anything.

However, it still works if I use eax, edi and edx, so should I use those rather than the full 64-bits? Why or why not?

  • 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-23T15:44:22+00:00Added an answer on May 23, 2026 at 3:44 pm

    First and foremost would be when loading a smaller (e.g. 8-bit) value from memory (reading a char, working on a data structure, deserialising a network packet, etc.) into a register.

    MOV AL, [0x1234]
    

    versus

    MOV RAX, [0x1234]
    SHR RAX, 56
    # assuming there are actually 8 accessible bytes at 0x1234,
    # and they're the right endianness; otherwise you'd need
    # AND RAX, 0xFF or similar...
    

    Or, of course, writing said value back to memory.


    (Edit, like 6 years later):

    Since this keeps coming up:

    MOV AL, [0x1234]
    
    • only reads a single byte of memory at 0x1234 (the inverse would only overwrite a single byte of memory)
    • keeps whatever was in the other 56 bits of RAX
      • This creates a dependency between the past and future values of RAX, so the CPU can’t optimise the instruction using register renaming.

    By contrast:

    MOV RAX, [0x1234]
    
    • reads 8 bytes of memory starting at 0x1234 (the inverse would overwrite 8 bytes of memory)
    • overwrites all of RAX
    • assumes the bytes in memory have the same endianness as the CPU (often not true in network packets, hence my SHR instruction years ago)

    Also important to note:

    MOV EAX, [0x1234]
    
    • reads 4 bytes of memory starting at 0x1234 (the inverse would overwrite 4 bytes of memory)
    • overwrites all of RAX, but the high bits will all be zero
      • see: Why do most x64 instructions zero the upper part of a 32 bit register

    Then, as mentioned in the comments, there is:

    MOVZX EAX, byte [0x1234]
    
    • only reads a single byte of memory at 0x1234
    • extends the value to fill all of EAX (and thus RAX) with zeroes (eliminating the dependency and allowing register renaming optimisations).

    In all of these cases, if you want to write from the ‘A’ register into memory you’d have to pick your width:

    MOV [0x1234], AL   ; write a byte (8 bits)
    MOV [0x1234], AX   ; write a word (16 bits)
    MOV [0x1234], EAX  ; write a dword (32 bits)
    MOV [0x1234], RAX  ; write a qword (64 bits)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand what System.WeakReference does, but what I can't seem to grasp is a
I understand that a .exe PE file can have CLI code in it. But
I understand how I can change the dns settings for my domains by editing
I understand that there are several ways to blend XNA and WPF within the
I understand the difference between String and StringBuilder ( StringBuilder being mutable) but is
I am trying to understand the object size difference between 32 bit and 64
I'm seeing: ld: in objs/AttributeValueTest.o, can't link with a main executable for architecture x86_64
How can I use configure and make tools to specify to use 64 bit
Is there a way to tell if the executing assembly is running in 32bit
From what I understand, if you're using the mvc:annotation-driven tag, then you can pass

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.