合肥工业大学汇编实验报告 下载本文

2.

;堆栈传递 Stack segment dw 512 dup(?) Stack ends Data segment

x dw 4 y dw 4 z dw ?

Data ends Code segment

assume cs:code, ds:data, ss:stack mov ax,data mov ds,ax sub sp,2 mov ax,x push ax mov ax,y push ax start:

call P1 pop z mov ax,z mov bx,ax mov dx,0 mov ch,4 mov cl,4 mov al,bl and al,0fh cmp al,0ah jl next add al,37h jmp down

add al,30h

again: rol bx,cl

next:

down: mov dl,al

mov ah,2 int 21h dec ch jnz again mov ah,4ch int 21h

push bp mov bp,sp push ax push bx push cx push dx mov ax,6[bp];x的值 mov bx,4[bp];y的值 imul bx

;x*y

P1 proc near

mov cx,dx ;x*y+x mov bx,ax

mov ax,6[bp] cwd add bx,ax adc cx,dx

mov ax,4[bp] cwd sub bx,ax sbb cx,dx

mov 8[bp],bx pop dx pop cx pop bx pop ax pop bp ret 4

;x*y+x-y

P1 endp Code ends

end start

寄存器传递

Stack segment

dw 512 dup(?) Stack ends Data segment

x dw 4 y dw 4 z dw ?

Data ends Code segment

assume cs:code, ds:data, ss:stack mov ax,data mov ds,ax mov ax,x mov bx,y call P1

mov z,bx; bx做出口参数 mov bx,z;方便查看输出是否正确 mov dx,0 mov ch,4 mov cl,4 mov al,bl and al,0fh cmp al,0ah jl next add al,37h jmp down

add al,30h

start:

again: rol bx,cl

next:

down: mov dl,al

mov ah,2 int 21h