汇编语言实验报告.doc_第1页
汇编语言实验报告.doc_第2页
汇编语言实验报告.doc_第3页
汇编语言实验报告.doc_第4页
汇编语言实验报告.doc_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

合肥工业大学计算机与信息学院实验报告课 程:汇编语言程序设计专业班级: 学 号:姓 名: 实验一 Debug程序的使用一. 实验目的1、熟悉DEBUG程序中的命令,学会在DEBUG下调试运行汇编语言源程序。2、掌握8086/8088的寻址方式及多字节数据的处理方法。二. 实验内容实验内容: 1、利用 DEBUG 程序中的“E”命令,将两个多字节数“12345678H”和 “FEDCBA98H”分别送入起始地址为DS:0200H 和DS:0204H 两个单元中。 2 、分别用直接寻址方式和寄存器间接寻址方式编写程序段,实现将 DS:0200H 单元和 DS:0204H 单元中的数据相加,并将运算结果存放在 DS:0208H 单元中。 实验要求: 本次实验的内容均在 DEBUG 下完成,实现数据的装入、修改、显示;汇 编语言程序段的编辑、汇编和反汇编;程序的运行和结果检查。 三. 实验过程和程序1、启动DOS 操作系统 2、运行DEBUG.COM 程序(若当前盘为 C) C: DEBUG ;(“ ”为DEBUG 提示符,仅当屏幕出现该提示符后,才可输入DEBUG 命令) 3、用“A”命令编辑和汇编源程序 A 186E :0100 MOV AX,0200 186E :0103 MOV BX,0202 186E :0107 ADD AX,0204 186E :010B ADC BX,0206 186E :010F MOV 0208,AX 186E :0112 MOV 020A,BX 186E :0116 4、用“U ”命令反汇编验证源程序 U CS:0100 186E :0100 A10002 MOV AX,0200 186E :0103 8B1E0202 MOV BX,0202 186E :0107 03060402 ADD AX,0204 186E :010B 131E0602 ADC BX,0206 186E :010F A30802 MOV 0208,AX 186E :0112 891E0A02 MOV 020A,BX 186E :0116 注意: 检查源程序是否有错误,若有则返回到第 3 步用“A 地址”命令进 行修改,直到程序无错误。 DEBUG 约定在其令或源程序中所涉及到的数据均被看作十六进 制数,其后不用“H”说明。 在DEBUG 下,源程序中不能使用“标号”、“变量”和一些伪指令。 在DEBUG 下,大小写不敏感。 5、程序未执行前,用“R”命令观察,相关寄存器的内容。 R 如:(AX )= 0000 ,(BX)= 0000 ,(SI)=0000 , (DI )=0000 ,(CS)= 0b58 ,(IP)= 0100 6、在程序未执行前,用“D”命令观察DS:0200H,DS:0204H、DS:0208H 单元的内容 D 200 20B 7、用“G”命令运行源程序 G =110 0116 8、再用“D”命令观察DS:0200HDS:020BH 字节单元中的内容 D 200 20B 9、用“T”单步操作命令对源程序单步执行,观察AX、BX、CS、IP 寄存 器内容的变化,并与预计的结果相比较。 注意: D 命令显示内存数据,注意观察多字节数据在内存中的存放方式。 指令执行的时候,IP 寄存器随着变化,注意观察。四. 实验结果(包括必要的截图)1、程序运行结果:(AX )= 1110,(BX )= 1111 DS:0208H 四字节单元的内容:1011 1111 2、试用寄存器间接寻址方式编写程序段,完成上述程序段的功能。程序流程图) 开始 SI200H DI204H BX208H AX SI DXSI+2 AXAX+DI DXDX+DI+2 BX(AX) BX+2(DX) 结束实验二 汇编语言程序设计(顺序、循环)一. 实验目的1、掌握顺序和循环程序结构和设计方法;2、熟悉在PC机上建立、汇编、连接、调试和运行8086/8088汇编语言程序的过程。二. 实验内容BL中只有一位为1.编写程序测试,并输出提示信息“the x bit is 1”,要求:地址表和转移表。地址表CR = 0dhLF = 0ahdseg segmentMsg1 db CR,LF,The 1 bit is 1,$Msg2 db CR,LF,The 2 bit is 1,$Msg3 db CR,LF,The 3 bit is 1,$Msg4 db CR,LF,The 4 bit is 1,$Addr dw Func0,Func1,Func2,Func3count dw 0dseg endscseg segment assume cs:cseg,ds:dsegStart: mov ax,dseg mov ds,ax mov bl,1 mov bh,0 mov cx,4Next: shr bl,1 cmp bl,0 je Handle inc count loop NextHandle: mov ax,count shl ax,1 mov bx,ax jmp AddrbxFunc0: lea dx,Msg1 jmp OutputFunc1: lea dx,Msg2 jmp OutputFunc2: lea dx,Msg3 jmp OutputFunc3: lea dx,Msg4 jmp OutputOutput: mov ah,09h int 21h mov ah,4ch int 21hcseg ends end Start 2学生成绩管理:在内存score缓冲区中存放100个学生的成绩数据,为无符号字节数,要求实现下面功能:给出不同分数段的人数 给出最高分,最低分,平均分 给定一个学生成绩,要求给出其名次三. 实验过程和程序CR = 0dhLF = 0ahdseg segmentscore db 90,80,30,60,50len = $-scorebeststr db =90:best db 0,;,CR,LF,$ betterstr db =80:better db 0,;,CR,LF,$ goodstr db =70:good db 0,;,CR,LF,$ passstr db =60:pass db 0,;,CR,LF,$ notpassstr db =60:notpass db 0,;,CR,LF,$inputscore db 4,?,4 dup(?)Msg1 db CR,LF,The highest score is:$Msg2 db CR,LF,The lowest score is:$Msg3 db CR,LF,The average score is:$Inputinfo db CR,LF,Please input score:$Rankinfo db CR,LF,Rank of this student is:rank db 1,;,CR,LF,$dseg endscseg segment assume ds:dseg,cs:csegStart: mov ax,dseg mov ds,ax;给出不同分数段的人数 mov bx,0 mov cx,lenLoop1: cmp scorebx,90 jb Next1 inc best jmp Done Next1: cmp scorebx,80 jb Next2 inc better jmp Done Next2: cmp scorebx,70 jb Next3 inc good jmp Done Next3: cmp scorebx,60 jb Next4 inc pass jmp Done Next4: inc notpass Done: inc bx loop Loop1 add best,30h lea dx,beststr mov ah,09h int 21h add better,30h lea dx,betterstr mov ah,09h int 21h add good,30h lea dx,goodstr mov ah,09h int 21h add pass,30h lea dx,passstr mov ah,09h int 21h add notpass,30h lea dx,notpassstr mov ah,09h int 21h ;输出最大 lea dx,Msg1 mov ah,09h int 21h mov cx,4 mov bx,0 mov al,scorebxLoop2: inc bx cmp al,scorebx ja jm mov al,scorebxjm: loop loop2 xor ah,ah mov bl,10 div bl add al,30h mov dl,al mov bh,ah mov ah,2 int 21h mov dl,bh add dl,30h mov ah,2 int 21h;输出最小 lea dx,Msg2 mov ah,09h int 21h mov cx,4 mov bx,0 mov al,scorebxLoop3: inc bx cmp al,scorebx jb jm1 mov al,scorebxjm1: loop loop3 xor ah,ah mov bl,10 div bl add al,30h mov dl,al mov bh,ah mov ah,2 int 21h mov dl,bh add dl,30h mov ah,2 int 21h ;输出平均 lea dx,Msg3 mov ah,09h int 21h mov cx,4 mov bx,0 xor ax,ax mov al,scorebxLoop4: inc bx add al,scorebx adc ah,0 loop loop4 mov dx,0 mov bl,5 mov bh,0 div bx mov bl,10 div bl add al,30h mov dl,al mov bh,ah mov ah,2 int 21h mov dl,bh add dl,30h mov ah,2 int 21h;给定一个学生成绩,给出其名次 lea dx,Inputinfo mov ah,09h int 21h lea dx,inputscore mov ah,0ah int 21h mov cl,inputscore+1 cmp cl,2 ja S100 jb S1 mov al,inputscore+2 sub al,30h mov ch,10 mul ch add al,inputscore+3 sub al,30h jmp GoS100: mov al,100 jmp GoS1: cmp cl,0 jz S0 mov al,inputscore+2 sub al,30h jmp GoS0: mov al,0Go: mov bx,0 mov cx,5loop5: cmp al,scorebx jae goon1 inc rankgoon1: inc bxloop loop5 add rank,30h lea dx,Rankinfo mov ah,09h int 21h mov ah,4ch int 21h cseg ends end Start 四 实验结果(包括必要的截图)实验三 汇编语言子程序设计(分支、子程序)一. 实验目的1、掌握分支和子程序结构和设计方法;2、熟悉在PC机上建立、汇编、连接、调试和运行8086/8088汇编语言程序的过程。3、通过汇编语言了解高级语言的参数传递等知识。二. 实验内容子程序设计:完成Word型二进制,十进制和十六进制的相互转换,包括从键盘输入和屏幕输出功能。要求:1. 功能选择。2. 转换使用子程序实现,且:二进制到十进制和十六进制转换使用内存传递参数;十进制到二进制和十六进制转换使用寄存器传递参数;十六进制到二进制和十进制转换使用堆栈传递参数。3. 输出使用子程序实现。三. 实验过程和程序data segment buf db 17,?,17 dup(?)Instru db Instruction:,0dh,0ah,0:change B to D.,0dh,0ah,1:change B to H.,0dh,0ah,2:change D to B.,0dh,0ah,3:change D to H.,0dh,0ah,4:change H to B.,0dh,0ah,5:change H to D.,0dh,0ah,6:End program.$ Msg db 0dh,0ah,Please input a function number(0-6):$Msg1 db 0dh,0ah,Please input a 16 bits Bin:$Msg2 db 0dh,0ah,Please input a 2 bits Dec:$Msg3 db 0dh,0ah,Please input a 4 bits Hex:$Msg4 db 0dh,0ah,Output the Bin:$Msg5 db 0dh,0ah,Output the Dec:$Msg6 db 0dh,0ah,Output the Hex:$Endpro db 0dh,0ah,End the program!$Procpt1 dw BtoDProcpt2 dw BtoHAddrtbl dw Func0,Func1,Func2,Func3,Func4,Func5,Func6data endsstack1 segment stack dw 512 dup (0)stack1 endscode segment assume cs:code,ds:data,ss:stack1Start: mov ax,data mov ds,ax lea dx,Instru mov ah,9 int 21hBegin: lea dx,Msg mov ah,9 int 21h mov ah,1 int 21h and ax,0fh shl ax,1 mov bx,ax jmp Addrtblbx Func0: call Procpt1 jmp BeginFunc1: call Procpt2 jmp BeginFunc2: lea si,buf call DtoB jmp BeginFunc3: lea si,buf call DtoH jmp BeginFunc4: lea ax,buf push ax call HtoB jmp BeginFunc5: lea ax,buf push ax call HtoD jmp BeginFunc6: lea dx,Endpro mov ah,9 int 21h mov ah,4ch int 21h BtoD proc push si push ax push bx push cx push dx lea dx,Msg1 mov ah,9 int 21h lea dx,buf mov ah,0ah int 21h lea dx,Msg5 mov ah,9 int 21h mov ax,8000h mov bx,0 mov cl,1 mov si,2Do: cmp bufsi,1 jz Do1 jmp Do2Do1: or bx,axDo2: shr ax,cl inc si cmp si,17 jbe Do mov ax,bx mov dx,0 mov cx,10000 div cx mov bx,dx and ax,00ffh add al,30h mov dl,al mov ah,2 int 21h mov ax,bx mov dx,0 mov cx,1000 div cx mov bx,dx and ax,00ffh add al,30h mov dl,al mov ah,2 int 21h mov ax,bx mov cl,100 div cl mov bh,ah add al,30h mov dl,al mov ah,2 int 21h mov al,bh mov ah,0 mov cl,10 div cl mov bh,ah add al,30h mov dl,al mov ah,2 int 21h add bh,30h mov dl,bh mov ah,2 int 21h pop dx pop cx pop bx pop ax pop si retBtoD endpBtoH proc push si push ax push bx push cx push dx lea dx,Msg1 mov ah,9 int 21h lea dx,buf mov ah,0ah int 21h lea dx,Msg6 mov ah,9 int 21h mov ax,8000h mov bx,0 mov cl,1 mov si,2Don: cmp bufsi,1 jz Don1 jmp Don2Don1: or bx,axDon2: shr ax,cl inc si cmp si,17 jbe Don Next1: mov dx,bx mov cl,12 shr dx,cl and dl,0fh cmp dl,09h jbe Output1 add dl,57h mov ah,2 int 21h jmp Next2Output1: add dl,30h mov ah,2 int 21h Next2: mov dx,bx mov cl,8 shr dx,cl and dl,0fh cmp dl,09h jbe Output2 add dl,57h mov ah,2 int 21h jmp Next3Output2: add dl,30h mov ah,2 int 21hNext3: mov dx,bx mov cl,4 shr dx,cl and dl,0fh cmp dl,09h jbe Output3 add dl,57h mov ah,2 int 21h jmp Next4Output3: add dl,30h mov ah,2 int 21hNext4: mov dx,bx and dl,0fh cmp dl,09h jbe Output4 add dl,57h mov ah,2 int 21h jmp ExitOutput4: add dl,30h mov ah,2 int 21hExit: pop dx pop cx pop bx pop ax pop siretBtoH endpDtoB proc push si push ax push bx push cx push dx lea dx,Msg2 mov ah,9 int 21h lea dx,buf mov ah,0ah int 21h lea dx,Msg4 mov ah,9 int 21h inc si mov cl,si xor ch,ch jcxz Exit1 cmp cl,1 jz Done1 cmp cl,2 jz Done2 jmp Exit1Done1: inc si mov bl,si sub bl,30h mov cx,8 jmp OutputaDone2: inc si mov bl,si sub bl,30h mov al,si sub al,30h mov cl,3 shl bl,cl mov cl,1 shl al,cl add bl,al inc si mov al,si sub al,30h add bl,al mov cx,8Outputa: mov dl,30h shl bl,1 jnc Skip inc dlSkip: mov ah,2 int 21h loop OutputaExit1: pop dx pop cx pop bx pop ax pop si retDtoB endpDtoH proc push si push ax push bx push cx push dx lea dx,Msg2 mov ah,9 int 21h lea dx,buf mov ah,0ah int 21h lea dx,Msg5 mov ah,9 int 21h inc si mov cl,si xor ch,ch jcxz Exit2 cmp cl,1 jz D1 cmp cl,2 jz D2 jmp Exit2D1: inc si mov bl,si mov dl,bl mov ah,2 int 21h jmp Exit2D2: inc si mov bl,si and bl,0fh mov al,si and al,0fh mov cl,3 shl bl,cl mov cl,1 shl al,cl add bl,al inc si mov al,si and al,0fh add bl,alOutputa0: mov al,bl push ax mov cl,4 shr bl,cl cmp bl,09h jbe D3 add bl,57h jmp Outputa1 D3: add bl,30hOutputa1: mov dl,bl mov ah,2 int 21h pop ax mov bl,al and bl,0fh cmp bl,09h jbe D4 add bl,57h jmp Outputa2D4: add bl,30hOutputa2: mov dl,bl mov ah,2 int 21h Exit2: pop dx pop cx pop bx pop ax pop si retDtoH endpHtoB proc push bp mov bp,sp push ax push bx push cx push dx push si lea

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论