合工大汇编语言程序设计实验报告 下载本文

again: shl bl,1 jc next add si,3 loop again next:

add si,offset jmptable jmp si jmptable: jmp near ptr l1 jmp near ptr l2 jmp near ptr l3 jmp near ptr l4 jmp near ptr l5 jmp near ptr l6 jmp near ptr l7 jmp near ptr l8 l1:

lea dx,str1 jmp output l2:

lea dx,str2 jmp output l3:

lea dx,str3 jmp output l4:

lea dx,str4 jmp output l5:

lea dx,str5 jmp output l6:

lea dx,str6 jmp output l7:

lea dx,str7 jmp output l8:

lea dx,str8 output: mov ah,9 int 21h MOV AH,4CH INT 21H CODES ENDS

END START (2)地址表

;地址表,bl左到右依次是第1-8位 DATAS SEGMENT

str1 db 'the 1 bit is 1',0dh,0ah,'$' str2 db 'the 2 bit is 1',0dh,0ah,'$' str3 db 'the 3 bit is 1',0dh,0ah,'$' str4 db 'the 4 bit is 1',0dh,0ah,'$' str5 db 'the 5 bit is 1',0dh,0ah,'$' str6 db 'the 6 bit is 1',0dh,0ah,'$' str7 db 'the 7 bit is 1',0dh,0ah,'$' str8 db 'the 8 bit is 1',0dh,0ah,'$'

addrtable dw show1,show2,show3,show4,show5,show6,show7,show8 DATAS ENDS

CODES SEGMENT

ASSUME CS:CODES,DS:DATAS START:

MOV AX,DATAS MOV DS,AX mov bl,00001000b mov cx,8

mov si,0 again: shl bl,1 jc next add si,2 loop again next:

jmp addrtable[si] show1: lea dx,str1 jmp output show2: lea dx,str2 jmp output show3: lea dx,str3 jmp output show4: lea dx,str4 jmp output show5: lea dx,str5 jmp output show6: lea dx,str6 jmp output show7: lea dx,str7 jmp output show8: lea dx,str8 jmp output output: mov ah,9

int 21h MOV AH,4CH INT 21H CODES ENDS

END START

实验内容二:编写一个子程序计算z=f(x,y)=x*y+x-y(x,y,z有符号数内存数) (1)堆栈传递参数

;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 sub sp,2 push y push x call cal pop z mov bx,z MOV AH,4CH INT 21H cal proc push bp mov bp,sp push ax push bx mov ax,[bp+4] mov bx,[bp+6] imul bx add ax,[bp+4] adc dx,0