Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Microprocessor & assembly language


Published on

Published in: Technology, Spiritual
  • Be the first to comment

  • Be the first to like this

Microprocessor & assembly language

  1. 1. Presentation Topic :PUSH, PUSHF, POP, POPFPresented By :
  2. 2. Contents : The Stack Push Pop PushF PopF
  3. 3. A stack in one-dimensional data structure. Items are added andremoved from one end of the structure; that is, it is processedin a “Last-in, first out” manner. The most recent addition to thestack is called the top of the stack.A program must set aside a block of memory to hold the stack.We have been dong this by declaring a stack segment ;For example :.STACK 100HTHE STACK
  4. 4. To add a new word to the stack we PUSH it on. The syntax isPUSH sourceWhere source is a 16-bit register or memory word.For example,PUSH AXExecution of PUSH causes the following to happen :1. SP is decreased by 2.2. A copy of the source content is moved to the address specifiedby SS:SP. The source is unchanged.PUSH AND PUSHF
  5. 5. The instruction PUSHF, which has no operands, pushesthe contents of the FLAGS register onto the stack.Initially SP contains the offset address of the memorylocation immediately following the stack segment; thefirst PUSH decreases SP by 2, making it point to the lastword in the stack segment. Because each PUSHdecreases SP, the stack grows toward the beginning ofmemoryPUSH AND PUSHF
  6. 6. FIGURE : EMPTY STACKoffset00F000F200FA00F400F600F800FC00FE01001234SP56780100AXBXSTACK(empty)SP
  7. 7. FIGURE : AFTER PUSH AXoffset00F000F200FA00F400F600F800FC00FE010012341234SP567800FEAXBXSTACKSP
  8. 8. FIGURE : AFTER PUSH BXoffset00F000F200FA00F400F600F800FC00FE0100567812341234SP567800FCAXBXSTACKSP
  9. 9. To remove the top item from the stack we POP it. The Syntax isPOP destinationWhere destination is a 16-bit register (except IP) or memory word. For example,POP BXExecuting POP causes this to happen:1. The content of SS:SP (the top the stack) is moved to the destination2. SP is increased by 2.POP AND POPF
  10. 10. The instruction POPF pops the top of the stack into the FLAGSRegister. There is no effect of PUSH, PUSHF, POP, POPF on the flags.Such asIllegal : PUSH DLIs illegal. So is a push of immediate data, such asIllegal : PUSH 2
  11. 11. FIGURE : BEFORE POPoffset00F000F200FA00F400F600F800FC00FE010056781234FFFFSP000100FCCXDXSTACkSP
  12. 12. FIGURE : AFTER POP CXoffset00F000F200FA00F400F600F800FC00FE0100567812345678SP000100FECXBXSTACKSP
  13. 13. FIGURE : AFTER POP DXoffset00F000F200FA00F400F600F800FC00FE0100567812345678SP12340100CXDXSTACK(empty)SP
  14. 14. THANK YOUEND