News:

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

How would you...

Started by Kyle, January 20, 2010, 09:03:16 PM

Previous topic - Next topic

Kyle

In C++ I have a line thats:

Temp [ 1 ] = Temp [ 2 ];

How would I do this in MASM? When I run it through MSVC it puts it out as:

mov al, BYTE PTR Temp [ebp+2]
mov BYTE PTR Temp[ebp+1], al


But would I really use EBP for this?

donkey

You would most likely just use the label, the assembler will generate the offset from EBP for locals and parameters. All local and parameter data resolves to an offset from either EBP (normally used for parameters) or ESP (normally used for locals). Of course since C++ sometimes uses EBP as a GPR all bets are off but I would suspect that temp is a parameter pushed onto the stack before the call. Since there is no 1/4 stack operation in 32 bit programming (ie you cannot push a single byte - all stack operations have to be DWORDs) the data is extracted as an offset from the temp label and resolved into byte sized chunks.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable