Special Topics: Microprocessor & Assembly Language

Special Topics: Microprocessor & Assembly Language
Slide Note
Embed
Share

This lecture explores the utilization of the stack segment in microprocessor programming, focusing on PUSH and POP operations with examples involving register AX. Learn about the stack organization in memory and the manipulation of stack pointer and registers in assembly language programming.

  • Microprocessor
  • Assembly Language
  • University of Basrah
  • Stack Segment
  • Programming

Uploaded on Feb 22, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. 2rd Grade Computer Science Dept/ College of Education for Pure Sciences Special Topics: Microprocessor & Assembly Language Lecture 7 Instructor: Ghazwan Abdulnabi Al-Ali University of Basrah, Iraq

  2. Microprocessor & Assembly Language University of Basrah The stack Stack is a segment of memory , it is 64kb in length and organized from software point view as 32kb words. During the subroutines call the contents of certain registers of 8088 are pushed to the stack, they are saved temporarily. At the completion of the subroutine these values are popped off the stack and put back into the same registers where they originally reside. When a call instruction is executed the 8088 automatically pushed the current values in CS and IP into the Stack. As indicated before the register (SS) holds the address of the stack segment and (SP) contains the Offset address. The address obtained from combining SS value with SP value is the physical address of the last storage location in the stack, this location is known as Top of stack (TOS). 2

  3. Microprocessor & Assembly Language University of Basrah PUSH & POP. Reg A. PUSH.reg: When push - instruction is applied to a register the following will occur: SP value is automatically decremented by 2 (SP=SP-2) The contents of Reg is saved_ in the stack at the address referred by SP. 1. 2. POP.Reg: When pop instruction is applied to a register the following will occur: The contents are popped from the stack and put back to it's register. SP value is automatically incremented by 2 (SP= SP +2). B. 1. 2. 3

  4. Microprocessor & Assembly Language University of Basrah Example suppose the following Stack segment :- And let SS = 01050 , SP= 0008 and AX=3A3C show what happen if we execute the instruction PUSH AX ? solution 0 1 0 5 0 0 0 0 8 __________ 0 1 0 5 8 this is the value of (TOS) 4

  5. Microprocessor & Assembly Language University of Basrah Example Cont. suppose the following Stack segment :- And let SS = 01050 , SP= 0008 and AX=3A3C show what happen if we execute the instruction PUSH AX ? solution 0 1 0 5 0 0 0 0 8 __________ 0 1 0 5 8 this is the value of (TOS) 5

  6. Microprocessor & Assembly Language University of Basrah Example Cont. MOV AX, 3A3C PUSH AX As indicted when push instruction applied to AX SP=SP-2 =TOS, 01058-2=01056. 6

  7. Microprocessor & Assembly Language University of Basrah Example POP. POP AX As indicted when POP instruction applied to AX SP=SP+2 =TOS, 01056+2=01058 , AX= 3A3C. 7

  8. Microprocessor & Assembly Language University of Basrah Flag register STATUS Register(Flag register) It is a 16 bit in length ,only nine of its bit are implemented , six of them are called status flags(they are automatically set after execution of arithmetic operation) CF (Carry Flag): is set(1) if there are a carry out or borrow in for the most significant bit during the execution of an arithmetic operation, other wise CF is reset (0). PF(Parity Flag):- It is set if the number of 1 s in the result ( of an arithmetic operation) is even other wise , it is set. 8

  9. Microprocessor & Assembly Language University of Basrah Flag register Cont. AF(Auxiliary Carry Flag):- It is set if there is a carry out from the low nibble to high nibble or borrow in from high nibble to low nibble, other wise it is reset. ZF (Zero Flag):- It is set if the result of an arithmetic operation is zero, else it is reset. SF (Sign Flag):- it is set if the result is negative and it is reset if the result is positive. the (MSB) (most significant bit) is copied into (SF), if I the result is negative , if zero it is positive. OF(Overflow Flag):- is set, it indicates that the signed result is out of range, if the result if not out of range is reset. 9

  10. Microprocessor & Assembly Language University of Basrah Control Flags The three other flags are called Control Flags: 1. TF (Trap Flag) :- if (TF) is set(1) that make 8088 goes in single-step mode(it executes one instruction at a time). 2. IF (Interrupt Flag):- to recognize interrupt request IF should be set (1) , if IF is reset the Interrupt request will be ignored. 3. DF (Direction Flag):- it determines the direction in which string operation will occur, if DF. is set the string instruction automatically decrements the address(from high address to low address), if DF is reset causes the string address to be incremented (from low address to high address). 10

  11. Microprocessor & Assembly Language University of Basrah Ex. Write an assembly language program to generate B where b is the inverse of A.(Use a stack) 11

  12. Microprocessor & Assembly Language University of Basrah Solution: 12

  13. Microprocessor & Assembly Language University of Basrah Thank You 13

More Related Content