Компьютерные основы программирования Представление программ часть3 Лекция 6, 16 и 23 марта 2017 Лектор: Чуканова Ольга Владимировна Кафедра информатики 602 АК ovcha@mail. ru
• _pcount • push • mov • xor • @1@58: • mov • and • mov • add • mov • shr • or • jne • mov • pop • ret proc far bp bp, sp bx, word ptr [bp+6] cx, cx ax, bx ax, 1 dx, cx dx, ax cx, dx bx, 1 bx, bx short @1@58 ax, cx bp
• _fib proc • push • mov • sub • xor • mov • @1@58: • mov • add • mov • inc • cmp • jl • mov • pop • ret far bp bp, sp sp, 2 dx, dx bx, bx cx, 1 ax, bx ax, cx word ptr [bp-2], ax bx, cx cx, word ptr [bp-2] dx dx, word ptr [bp+6] short @1@58 ax, bx sp, bp bp
• _fib 1 • push • mov • sub • mov • jmp • @1@58: • mov • add • mov • inc • @1@86: • cmp • jl • mov • pop • ret proc far bp bp, sp sp, 2 dx, 1 bx, 1 cx, 1 short @1@86 ax, bx ax, cx word ptr [bp-2], ax bx, cx cx, word ptr [bp-2] dx dx, word ptr [bp+6] short @1@58 ax, bx sp, bp bp
i=1 i
• _fib 2 • push • mov • sub • mov • jmp • @1@58: • mov • add • mov • inc • @1@114: • cmp • jl • mov • pop • ret proc far bp bp, sp sp, 2 bx, 1 cx, 1 dx, 1 short @1@114 ax, bx ax, cx word ptr [bp-2], ax bx, cx cx, word ptr [bp-2] dx dx, word ptr [bp+6] short @1@58 ax, bx sp, bp bp
Процедуры Структура стекового фрейма
_caller proc push mov sub mov lea push call add mov 12], eax mov 4] sub 8] mov pop ret far ebp, esp, 16 dword ptr [ebp-4], 5 dword ptr [ebp-8], 3 eax, dword ptr [bp-8] eax, dword ptr [bp-4] eax near ptr _swap_add esp, 16 dword ptr [ebpeax, dword ptr [ebpesp, ebp
_swap_add push mov lea [ebp+8] mov lea [ebp+12] mov add pop ret proc far ebp, esp ebx, dword ptr edx, dword ptr [ebx] ebx, dword ptr ecx, dword ptr [ebx] ebx, dword ptr [ebx], ecx ebx, dword ptr [ebx], edx eax, ecx ebp
Рекурсивные процедуры
_fib proc push mov sub push mov cmp jg mov @1@86: jmp @1@114: mov add push call mov dec push call far bp bp, sp sp, 4 si si, word ptr [bp+6] si, 2 short @1@114 ax, 1 short @1@142 ax, si ax, -2 ax near ptr _fib word ptr [bp-2], ax ax, si ax ax near ptr _fib mov word ptr [bp-4], ax mov ax, word ptr [bp-2] add ax, word ptr [bp-4] jmp short @1@86 @1@142: pop si mov sp, bp pop bp ret _fib endp