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.
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:
append length of message (before pre-processing), in bits,
as 64-bit big-endian integer
The only things that come to mind is to, for example represent the number 1 as:
[63 0's]1
Or
1[63 0's]
Or
[31 0's] 1 [32 0's]
Basically my thought so far is basically:
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
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.
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.
The binary representation of the number 1 as a big-endian 64-bit integer is