Declaring local variables in assembly

Posted by dcmoebius on Stack Overflow See other posts from Stack Overflow or by dcmoebius
Published on 2010-03-17T08:07:42Z Indexed on 2010/03/17 8:11 UTC
Read the original article Hit count: 334

Filed under:
|
|

Is it possible to allocate locally-scoped memory in assembly?

For example, consider the following (completely contrived) situation:

I have two macros, one of which is dependent on the other. The first is:

minimum MACRO dest, num1, num2
; Finds the minimum of two unsigned numbers, stores the result in dest

And the second is:

tripMin MACRO dest, num1, num2, num3
; Finds the minimum of three unsigned numbers, stores the result in dest

minimum firstMin, num1, num2
minimum secondMin, num2, num3
minimum dest, firstMin, secondMin

(I know that this isn't a realistic example for a variety of reasons, but bear with me.)

Assuming that all the registers are otherwise occupied, is there any way to declare firstMin and secondMin locally within the macro?

Or am I just better off freeing a register by pushing its value onto the stack and popping it back when I'm done?

© Stack Overflow or respective owner

Related posts about assembly

Related posts about scope