Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Push and Pop

PhilosophaiePhilosophaie Member Posts: 2
Here is a simple Question for an x86 Microprocessor in Assembly Code. When a [PUSH reg] command is executed does the Stack Pointer get Decremented before or after the [reg] gets added to the stack. Same goes for the [POP reg] does the SP get incremented befor or after reading the [reg].

Comments

  • MT2002MT2002 Member Posts: 1,444
    : Here is a simple Question for an x86 Microprocessor in Assembly
    : Code. When a [PUSH reg] command is executed does the Stack Pointer
    : get Decremented before or after the [reg] gets added to the stack.
    : Same goes for the [POP reg] does the SP get incremented befor or
    : after reading the [reg].
    :

    SP gets updated after adding [reg] into the stack.
    [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS Operating System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[rightbr][/link][/size]
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [color=Blue]
    Just run a debugger and enter the PUSH and POP instructions and watch registers, when stepping line by line.
    [/color]
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    Ohhh... you guys are evil ;)

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • BretBret Member Posts: 114
    : : Here is a simple Question for an x86 Microprocessor in Assembly
    : : Code. When a [PUSH reg] command is executed does the Stack Pointer
    : : get Decremented before or after the [reg] gets added to the stack.
    : : Same goes for the [POP reg] does the SP get incremented befor or
    : : after reading the [reg].
    : :
    :
    : SP gets updated after adding [reg] into the stack.
    : [hr][size=1][leftbr].:EvolutionEngine[rightbr][leftbr].:MicroOS
    : Operating
    : System[rightbr][leftbr][link=http://www.mt2002.sitesled.com]Website[r
    : ightbr][/link][/size]

    Actually, it depends on the CPU. Some do it before and some do it after. That was one of the ways to differentiate between some of the CPU's in the old days (before the CPUID instruction existed).
  • m34tb34tm34tb34t Member Posts: 25
    80286 and after push the value then decriment sp.
    8086 and 80186 chips decriment sp then push the value.
    The Intel documented method for detecting the presence of a 186 chip involves
    [code]
    PUSH SP
    POP AX
    CMP AX,SP
    [/code]
    or something along those lines....
Sign In or Register to comment.