The stack University of Technology 8085 microproce

Department of Control and Systems Engineering Lecture 2 – Page 8 of 10 . Third Year - Microprocessors By Mr.WaleedFawwaz

9. The stack

The stack is implemented in the memory and it is used for temporary storage of information such as data and addresses. The stack is 64Kbytes long and is organized from a software point of view as 32Kwords see Fig 10. • SS register points to the lowest address word in the stack • SP and BP points to the address within stack • Data transferred to and from the stack are word-wide, not byte-wide. • The first address in the Stack segment SS : 0000 is called End of Stack. • The last address in the Stack segment SS : FFFE is called Bottom of Stack. • The address SS:SP is called Top of Stack. • POP instruction is used to read wordfrom the stack. • PUSH instruction is used to write word to the stack. • When a word is to be pushed onto the top of the stack: o the value of SP is first automatically decremented by two o and then the contents of the register written into the stack. • When a word is to be popped from the top of the stack the o the contents are first moved out the stack to the specific register o then the value of SP is first automatically incremented by two. Fig 10: Stack segment of memory Example 5: let AX=1234H ,SS=0105H and SP=0006H. Fig 11 shows the state of stack prior and after the execution of next program instructions: PUSH AX POP BX POP AX Department of Control and Systems Engineering Lecture 2 – Page 9 of 10 . Third Year - Microprocessors By Mr.WaleedFawwaz Fig 11PUSH and POP instruction 10. Input and Output address space The 8086 has separate memory and inputoutput IO address spaces. The IO address space is the place where IOinterfaces, such as printer and monitor ports, are implemented. Notice that this address range is form 0000H to FFFFH. This represents just 64Kbyte addresses; therefore only 16 bits of address are needed to address IOspace. 01054 01055 01056 01057 01050 01051 01052 01053 01058 01059 0105A 0105B SS SP BX 0105 0006 5D00 55 1F DF DD 02 00 C0 52 90 68 A2 55 01054 01055 01056 01057 01050 01051 01052 01053 01058 01059 0105A 0105B SS SP BX 0105 0004 5D00 34 12 DF DD 02 00 C0 52 90 68 A2 55 01054 01055 01056 01057 01050 01051 01052 01053 01058 01059 0105A 0105B SS SP BX 0105 0006 1234 34 12 DF DD 02 00 C0 52 90 68 A2 55 01054 01055 01056 01057 01050 01051 01052 01053 01058 01059 0105A 0105B SS SP BX 0105 0008 1234 34 12 DF DD 02 00 C0 52 90 68 A2 55 a Initial state b After execution of PUSH AX d After execution of POP AX c After execution of POP BX AX 1234 AX 1234 AX 1234 AX DDDF Department of Control and Systems Engineering Lecture 2 – Page 10 of 10 . Third Year - Microprocessors By Mr.WaleedFawwaz Problems 1. What are the length of the 8086’s address bus and data bus? 2. How large is the instruction queue of the 8086? 3. List the elements of the execution unit. 4. What is the maximum amount of memory that can be active at a given time in the 8086? 5. Which part of the 8086’s memory address space can be used to store the instruction of a program? 6. Name two dedicated operations assigned to the CX register. 7. Calculate the value of each of the physical addresses that follows. Assume all numbers are hexadecimal numbers. a A000 : ? =A0123 b ? : 14DA =235DA c D765 : ? =DABC0 d ? : CD21 =32D21 8. If the current values in the code segment register and the instruction pointer are 0200 16 AND 01AC 16 9. If the current values in the stack segment register and stack pointer are C000 , respectively, what physical address is used in the next instruction fetch?. 16 and FF00 16 , respectively, what is the address of the current top of the stack? Department of Control and Systems Engineering Lecture 3 – Page 1 of 8 . Third Year - Microprocessors By Mr.WaleedFawwaz Lecture 3- Addressing MODES

1. Introduction to assembly language programming