News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

the stack

Started by Kyoy, December 24, 2004, 05:50:23 AM

Previous topic - Next topic

Ratch

Kyoy,
    Everything is working like it was designed to do, AFU.  If you do a BYTE 10H,20H,30H,40H, you can be SURE that MASM will copy the bytes beginning at the address in the same order you specified.  Each byte is a separate consecutive copy operation with no reference to the byte that came before or after it.  If you do a DWORD 10203040H, then the order of bytes assembled at the address is in 40H,30H,20H,10H order from  the low to high address, as I mentioned before in my previous post.  Therefore, if you read the byte for address+3 from BYTE 10H,20H,30H,40H, you will pick up 40H.  if you read the byte for address+3 from DWORD  10203040H, you will pick up the 10H byte.  If you read is as MOV EAX,ADDRESS , then the INTEL hardware will reverse the four bytes at that address and move them into EAX in a reversed order from what they were at the address.  This reversal means the value in EAX will be 10203040H for data specified by DWORD 10203040H, and 40302010H for data specified by BYTE 10H,20H,30H,40H .  Ratch

Kyoy

I understand now thanks. All along i was confused because i wasnt aware by declaring them as bytes, it was taken as a "separate consecutive copy operation "

Quote from: Ratch
If you read is as MOV EAX,ADDRESS , then the INTEL hardware will reverse the four bytes at that address and move them into EAX in a reversed order from what they were at the address
So , i can take it that by dereferecing ebx (mov eax,[ebx]) and storing them in another register it wont look like it was reversed but it was actually reversed twice already ( 10203040h to 40302010h when stored in address then back to 10203040h when stored in another register again)

Ratch

#17
Kyoy,
     Make sure you understand what the MASM does and what the INTEL CPU does.  They are in cahoots here.  MASM creates the value of a DWORD that will be correct when the CPU reverses the bytes from memory when loaded into a ERX register.  A register to memory load also reverses the bytes written to memory.  A register to register load stays the same, no reversal.  By the way, you don't have do a address load into a register first like you did with EBX.  Even if you defined the PROMPT label with a BYTE directive, you can code MOV EAX,DWORD PTR PROMPT, and the assembler will take PROMPT to be a DWORD and not give you an error.  Ratch