Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TASM 2.x / MASM 6.x Assembly Language - <b>enter enter stack frame (186/286/386) flags: o d i t s z a p c</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
ENTER            Enter Stack Frame (186/286/386)     Flags: O D I T S Z A P C

ENTER #locals, nesting

           Logic:          push BP
                           temp . SP
                           while(nesting > 0)
                               nesting . nesting - 1
                               BP . BP - 2
                               push SS:[BP]
                           end
                           BP . temp
                           SP . SP - #locals
           Note: for 386, convert all registers to extended versions, and
                 subtract 4 from BP each iteration.

     ENTER creates a stack frame. It saves the previous stack frame
     pointer BP, sets the frame to the current stack top, and allocates
     space for local variables. Parameters passed to the procedure are
     stored at positive offsets from BP; local variables are stored at
     negative offsets from BP.

     For example, ENTER n,0 (which creates a stack frame with space for n
     bytes) is equal to these instructions:

                        PUSH    BP
                        MOV     BP, SP
                        SUB     SP, n

     If nesting of procedure definitions is allowed in the calling language
     (allowed in Pascal, Modula 2, or Ada), pointers to the previous stack
     frame are pushed onto the stack so that you can address variables on the
     stack whose scopes are outside the current stack frame.

  --------------------------------------------------------------------------
   Operands                   Clocks   Transfers  Bytes  Example
   ENTER immediate16,0        11 (286)     -        4    ENTER NUMBYTES,0
   ENTER immediate16,1        15 (286)     -        4    ENTER NUMBYTES,1
  --------------------------------------------------------------------------

See Also: LEAVE

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson