tailieunhanh - Lecture Computer organization and assembly language - Lecture 15: STACK Related Instructions

In this lecture, students will be able to understand: STACK Operations, Runtime Stack, PUSH Operation, POP Operation, PUSH and POP Instructions, Using PUSH and POP, Related Instructions, PUSH and POP Instructions, Using PUSH and POP, Related Instructions. | CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions Lecture 14: Review Instruction Execution in Assembly Assembly Language Examples: Control Flow JMP Instruction LOOP Instruction LOOP Example Summing an Integer Array Lecture Outline STACK Operations Runtime Stack PUSH Operation POP Operation PUSH and POP Instructions Using PUSH and POP Related Instructions Runtime Stack Imagine a stack of Plates . . . Plates are only added/removed to/from the top LIFO (Last In First Out) structure 10 9 8 7 6 5 4 3 2 1 Top Bottom Runtime Stack Managed by the CPU, using two registers SS (stack segment) ESP (stack pointer) * * SP in Real-address mode 00000006 00001000 00000FFC 00000FF8 00000FF4 00000FF0 Memory Stack ESP PUSH Operation (1 of 3) A 32-bit push operation decrements the stack pointer by 4 and copies a value into the location pointed to by the stack pointer. 00000006 00001000 00000FFC 00000FF8 00000FF4 00000FF0 Memory Stack ESP 00000006 000000A5 00001000 | CSC 221 Computer Organization and Assembly Language Lecture 15: STACK Related Instructions Lecture 14: Review Instruction Execution in Assembly Assembly Language Examples: Control Flow JMP Instruction LOOP Instruction LOOP Example Summing an Integer Array Lecture Outline STACK Operations Runtime Stack PUSH Operation POP Operation PUSH and POP Instructions Using PUSH and POP Related Instructions Runtime Stack Imagine a stack of Plates . . . Plates are only added/removed to/from the top LIFO (Last In First Out) structure 10 9 8 7 6 5 4 3 2 1 Top Bottom Runtime Stack Managed by the CPU, using two registers SS (stack segment) ESP (stack pointer) * * SP in Real-address mode 00000006 00001000 00000FFC 00000FF8 00000FF4 00000FF0 Memory Stack ESP PUSH Operation (1 of 3) A 32-bit push operation decrements the stack pointer by 4 and copies a value into the location pointed to by the stack pointer. 00000006 00001000 00000FFC 00000FF8 00000FF4 00000FF0 Memory Stack ESP 00000006 000000A5 00001000 00000FFC 00000FF8 00000FF4 00000FF0 ESP AFTER BEFORE PUSH Operation (1 of 3) A 32-bit push operation decrements the stack pointer by 4 and copies a value into the location pointed to by the stack pointer. 00000006 000000A5 00001000 00000FFC 00000FF8 00000FF4 00000FF0 ESP AFTER PUSH Operation (1 of 3) A 32-bit push operation decrements the stack pointer by 4 and copies a value into the location pointed to by the stack pointer. 00000006 000000A5 00001000 00000FFC 00000FF8 00000FF4 00000FF0 ESP AFTER PUSH Operation (2 of 3) Same stack after pushing one more integer: 00000006 000000A5 00000001 00001000 00000FFC 00000FF8 00000FF4 00000FF0 ESP PUSH Operation (3 of 3) Same stack after pushing one more integer: The area in the direction ESP grows, is always available (unless the stack has overflowed). 00000006 000000A5 00000001 00000002 00001000 00000FFC 00000FF8 00000FF4 00000FF0 ESP POP Operation Copies value at stack[ESP] into a register or variable. Adds n to ESP, where n is either 2 or .

TÀI LIỆU MỚI ĐĂNG
18    130    0    26-12-2024