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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:18:16+00:00 2026-05-20T15:18:16+00:00

Say you are writing compilers for different architectures. The architectures have different endianness. You

  • 0

Say you are writing compilers for different architectures.
The architectures have different endianness.
You have memory read and write instructions

Take example of a store instruction, where you want to store the value 0xAA0xBB0xCC0xDD.
Now while writing the assembly for this, do you write two different instructions for the
different architectures e.g.

For the little endian: st (reg), 0xDD0xCC0xBB0xAA

For the big endian: st (reg), 0xAA0xBB0xCC0xDD

Or you write the same instruction, say, st, (reg), 0xAA0xBB0xCC0xDD for both the architectures and let the instruction be parsed by the processor such that it takes care of the endianness of the system?

The reason why I ask this question is I don’t know what a binary translator would do when it has to translate code between architectures of different endianness. If in Architecture A, you see the following line st, (reg), XY do you convert it into st, (reg), YX for the Architecture B ?? If that is the case, then what happens to memory reads?

I would like to know how to take care of endianness, considering memory reads and writes in binary translation.

  • 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-20T15:18:17+00:00Added an answer on May 20, 2026 at 3:18 pm

    I’m not sure I understand your question fully, but it sounds like you want to translate some assembly-language code or a disassembled binary?

    Every assembler I’ve ever worked with handles the endianness of constants in the sane way. That is to say, if you want to store 0xAABBCCDD, you would write:

    st (reg), 0xAABBCCDD
    

    And the assembler will swizzle the contstant if necessary for the appropriate opcode. Where endianness becomes a concern is where you want to store multiple single-byte values using that one operation. Something like writing a short null-terminated string "123" to memory using the same opcode. You have to swizzle that constant in your assembly code to get it output to memory in the right order for little- vs. big-endian systems:

    st (reg), 0x31323300 // big-endian
    st (reg), 0x00333231 // little-endian
    

    The safe way is to just store the bytes in the order you want them:

    stb (reg+0), 0x31
    stb (reg+1), 0x32
    stb (reg+2), 0x33
    stb (reg+3), 0x00
    

    But that takes four instructions, instead.

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

Sidebar

Related Questions

Once upon a time, to write x86 assembler, for example, you would have instructions
Lets say I am writing Dijkstra's Algorithm , and I have a priority queue
Let's say you are writing a library and you have a bunch of utility
Lets say that I am writing a program that supports plugins and I write
Say I have this sample code I'm writing for a Python lesson I'm holding:
Let's say I have some generic interface IMyInterface<TParameter1, TParameter2> . Now, if I'm writing
Let's say you're writing the software for Blogger. Each user can create a blog
Let's say I am writing installation script for the program which contains executable file
So, lets say I'm writing a web server and I want to support very
That is to say, let's say I'm writing something that's hosted on foo.com .

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.