Al diseñar el 80286, los diseñadores de CPU de Intel decidieron agregar dos instrucciones para ayudar a mantener las pantallas.
Aquí el código micro dentro de la CPU:
; ENTER Locals, LexLevel
push bp ;Save dynamic link.
mov tempreg, sp ;Save for later.
cmp LexLevel, 0 ;Done if this is lex level zero.
je Lex0
lp:
dec LexLevel
jz Done ;Quit if at last lex level.
sub bp, 2 ;Index into display in prev act rec
push [bp] ; and push each element there.
jmp lp ;Repeat for each entry.
Done:
push tempreg ;Add entry for current lex level.
Lex0:
mov bp, tempreg ;Ptr to current act rec.
sub sp, Locals ;Allocate local storage
Alternativa a ENTER sería:
; ingrese n, 0; 14 ciclos en el 486
push bp ;1 cycle on the 486
sub sp, n ;1 cycle on the 486
; ingrese n, 1; 17 ciclos en el 486
push bp ;1 cycle on the 486
push [bp-2] ;4 cycles on the 486
mov bp, sp ;1 cycle on the 486
add bp, 2 ;1 cycle on the 486
sub sp, n ;1 cycle on the 486
; ingrese n, 3; 23 ciclos en el 486
push bp ;1 cycle on the 486
push [bp-2] ;4 cycles on the 486
push [bp-4] ;4 cycles on the 486
push [bp-6] ;4 cycles on the 486
mov bp, sp ;1 cycle on the 486
add bp, 6 ;1 cycle on the 486
sub sp, n ;1 cycle on the 486
Ect. El largo camino puede aumentar el tamaño de tu archivo, pero es mucho más rápido.
en la última nota, el programador ya no usa la pantalla ya que fue un trabajo muy lento, lo que hace que ENTRAR sea bastante inútil ahora.
Fuente: https://courses.engr.illinois.edu/ece390/books/artofasm/CH12/CH12-3.html
http://stackoverflow.com/questions/5474355/about-leave-in-x86-assembly?rq=1 –