The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Kyle on January 20, 2010, 09:03:16 PM

Title: How would you...
Post by: Kyle on January 20, 2010, 09:03:16 PM
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?
Title: Re: How would you...
Post by: donkey on January 20, 2010, 09:24:32 PM
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.