合工大汇编语言程序设计实验报告

sub ax,[bp+6] sbb dx,0 mov [bp+8],ax pop bx pop ax pop bp ret 4 cal endp CODES ENDS END START (2)寄存器传递参数

;z=x*y+x-y,x、y、z为有符号数,寄存器传递 DATAS SEGMENT x dw 5 y dw 2 z dw ? DATAS ENDS CODES SEGMENT

ASSUME CS:CODES,DS:DATAS START:

MOV AX,DATAS MOV DS,AX mov ax,x mov bx,y call cal mov z,ax MOV AH,4CH INT 21H cal proc mov cx,ax imul bx add ax,cx adc dx,0 sub ax,bx sbb dx,0 ret

cal endp CODES ENDS END START (3)内存传递参数

;z=x*y+x-y,x、y、z为有符号数,内存传递 DATAS SEGMENT x dw 5 y dw 2 z dw ? DATAS ENDS CODES SEGMENT

ASSUME CS:CODES,DS:DATAS START:

MOV AX,DATAS MOV DS,AX call cal MOV AH,4CH INT 21H cal proc mov ax,x imul y add ax,x adc dx,0 sub ax,y sbb dx,0 mov z,ax ret cal endp CODES ENDS END START

实验内容三:实践C—>ASM的转换过程 _TEXT SEGMENT _c$ = -32 _b$ = -20 _a$ = -8

; size = 2 ; size = 2

; COMDAT

; size = 2

_main PROC

; 4 : void main(){

push mov push push push mov mov

ebp ebp, esp

; 000000e4H

ebx esi edi ecx, 57

; 00000039H

; ccccccccH

sub esp, 228

lea edi, DWORD PTR [ebp-228]

eax, -858993460

rep stosd

short a,b,c; eax, 1

WORD PTR _a$[ebp], ax b=a+1;

; 5 : ; 6 :

mov mov

; 7 : a=1;

; 8 :

movsx eax, WORD PTR _a$[ebp] add eax, 1 mov

WORD PTR _b$[ebp], ax c=a+b;

; 9 :

movsx eax, WORD PTR _a$[ebp] movsx ecx, WORD PTR _b$[ebp] add eax, ecx mov

WORD PTR _c$[ebp], ax

; 10 : ; 11 : ; 12 : }

xor eax, eax pop edi pop esi pop ebx mov pop ebp ret 0

esp, ebp

_main ENDP

_TEXT ENDS

四. 实验结果(包括必要的截图)

实验内容一:

(1) 转移表:设bl=00010000b

(2)地址表:设bl=00001000b

实验内容二:设x=5,y=2,则z=13(000D),结果在ax (1) 堆栈传递参数(结果在bx中查看)

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4