Laptop shows

These materials are somewhat close to what was shown in class via the laptop.
These are insufficient as they are.
Your in class notes must be added to these pages to understand what is going on.
These also include any corrections made in class that I could remember.

Since these are used in class to show that some things don't work, make sure you have gone through your class notes as you read these so which things here are negative examples or errors.

Also, there may simply be errors here. If you think you've found one, email me.

The format of these materials may not be what should be used in your code as I have little control over how some things align here.



The STACK

It's a sequence of words (not bytes) (or dwords for extended)

We must have one to use it:

.stack Ah ; a rather small stack!
          ; does anyone see the error?

PUSH   r
            m
             i  (286 and beyond)
FLAGS: none
SP decremented by 2 (or 4 for dwords)
(PUSHD for dwords)

POP	r
	m
FLAGS: none
SP incremented by 2 (or 4 for dwords)
(POPD for dwords)

Given SP contains 2000h
Consider:

    mov AX, 1234h
    mov BX, 8888h
    push ax
    push bx
    ; do something here like CALL a PROC (invoke a subroutine)
    pop bx  ; note the order here
    pop ax

Consider

    mov AX, 1234h
    mov BX, 8888h
    push ax
    push bx
    pop ax  ; note the order here
    pop bx  ; is this a "swap"

Don't speak aloud for this. It's a thought question. THINK your answer:
Consider a recursive function call and the stack if infinite recursion were to occur.

We can push the contents of the FLAGS (or EFLAGS) register
PUSHF
FLAGS: none
SP decremented by 2 (or 4 for dwords)
(PUSHD for dwords)

POPF
FLAGS: all!!!
SP incremented by 2 (or 4 for dwords)
(POPD for dwords)

We can push the contents of all eight registers
PUSHA
FLAGS: none
SP decremented by 2 (or 4 for dwords)
(PUSHD for dwords)

POPA
FLAGS: all!!!
SP incremented by 2 (or 4 for dwords)
(POPD for dwords)

These are stored in this order on the stack: DI, SI, BP, SP, BX, DX, CX, AX.
We don't really care about this order unless we don't indend to do a POPA do we?