פרק 6 המחסנית ותת תכניות

  • View
    24

  • Download
    0

Embed Size (px)

Transcript

-

- 6

. , , .

. . .6.1 stack6.1.1 ?6.1.1.1

LIFO LastInFirstOut

10h .

(stack segment).

( SS) . . SS.

6.1.1.2 ????????000F????????000E????????000D????????000C????????000B????????000A????????0009????????0008????????0007????????0006????????0005????????0004????????0003????????0002????????0001????????0000 12h000F34h000E00h000D7Fh000C????????000B????????000A????????0009????????0008????????0007????????0006????????0005????????0004????????0003????????0002????????0001????????0000 . : F000????????000F????????000E????????000D????????000C????????000B????????000A????????0009????????0008????????0007????????0006????????0005????????0004????????0003????????0002????????0001????????0000 16 =2 . 8 . : 1234h -7Fh . SP . SP 10h. 000Ch12h000F34h000E00h000D7Fh000C????????000B????????000A????????0009????????0008????????0007????????0006????????0005????????0004????????0003????????0002????????0001????????0000tosbos6.1.2 6.1.2.1 push opnd PUSH . SP 2 . .

' 179- .' 180 - 6.2 .6.1.2.2 pop opnd POP . SP 2 . .

' 183- .' 184-185 6.3 -6.7 .6.1.2.3 (stack over/underflow) . . .

6.2 - 6.2.1 label:{ -}ret6.2.2 - CALL label

- label . 3 call call . IP. IP ( )

' ' 191

- ret call ret IP

- end .

' ' 193 , AH -AL. AH -AL. , .

6.3 - : . . .

..model small.stack 100h.data.codebegin: mov ax, @data mov ds , as mov ah,[50h] mov bh,[51h] mov ch,[52h] mov dh,[53h] call add_numberssof: mov ah,4ch Int 21hadd_numbers: mov dl, 0 - ; add dl, ahadd dl, bhadd dl, chadd dl, dhret end .model small.stack 100h.data.codemov ax, @datamov ds , asbegin: call add_numberssof: mov ah,4ch Int 21hadd_numbers: mov ah,[50h] - ; mov bh,[51h]mov ch,[52h]mov dh,[53h] mov dl, 0add dl, ahadd dl, bhadd dl, chadd dl, dhret end20 .model small.stack 100h.datax db 5y db 10z db 20w db 17sum db 0.codemov ax, @datamov ds , asbegin: call add_numberssof: mov ah,4ch Int 21hadd_numbers:mov ah, 0 - ; add ah , xadd ah, yadd ah, zadd ah, wmov sum, ahret end21 - /.

- .model small.stack 100h.data.codemov ax, @datamov ds , asbegin:mov ah ,0mov al, [50h]push axmov al, [51h]push axmov al, [52h]push axmov al, [53h]push axcall add_numberssof: mov ah,4ch Int 21hadd_numbers:pop bx - ; pop ax pop dxadd dl, al pop axadd dl, al pop axadd dl, alpush bxret end 20 .( - ) 20 50h .

-175.