Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would I append a 64-bit Big-Endian int in ASM?
    primarykey
    data
    text
    <p>I am new to Assembly, but not new to programming and how it works in general. Because I know quite a few languages already, I decided to make my first ASM program calculate the SHA-1 hash of input files. I already have many of the separate parts worked out, but there are two parts I am having trouble with; one I will ask for help with here.</p> <p>Basically, I am confused over the concepts of Big and Little endian numbers and how to represent them in ASM. To quote from the SHA-1 Psuedocode:</p> <pre><code>append length of message (before pre-processing), in bits, as 64-bit big-endian integer </code></pre> <p>The only things that come to mind is to, for example represent the number 1 as:</p> <pre><code>[63 0's]1 </code></pre> <p>Or</p> <pre><code>1[63 0's] </code></pre> <p>Or</p> <pre><code>[31 0's] 1 [32 0's] </code></pre> <p>Basically my thought so far is basically:</p> <pre><code>mov eax, message ;Move message to be hashed into eax shl eax, 64 ;Shift message over enough bits to store 64-bits or eax, msglen ;Adds message length to the very end of message </code></pre> <p>This is most likely wrong, as this all uses 32-bit registers therefore shifting left 64-bits would create a huge overflow but that is just another problem I have yet to work out.</p> <p>I think I've gone way off track, but basically my question is is the above code a correct way to append a big-endian integer? Or do I have it backwards, or am I just completely off on everything, etc. Not sure if this makes sense, too tired.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload