第一范文网 - 专业文章范例文档资料分享平台

合肥工业大学汇编程序设计实验报告完整代码

来源:用户分享 时间:2025/5/19 20:39:57 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

实验三 汇编语言子程序设计(分支、子程序)

一. 实验目的

1、掌握分支和子程序结构和设计方法;

2、熟悉在PC机上建立、汇编、连接、调试和运行8086/8088汇编语言程序的过程。 3、通过汇编语言了解高级语言的参数传递等知识。

二. 实验内容

1、BL中的只有一位为1。编写程序测试,并输出提示信息“The X Bit is 1”,要求:地址表和转移表。

2. 编写一个子程序计算z=f(x,y)=x*y+x-y(x,y,z有符号数内存数)。要求通过堆栈(寄存器、内存)传送所有参数。 3. 实践C?Asm的转换过程。

三. 实验过程和程序

1、BL中的只有一位为1。编写程序测试,并输出提示信息“The X Bit is 1”,要求:地址表和转移表。 ;bl have one 1 cout<

addres dw fun8,fun7,fun6,fun5,fun4,fun3,fun2,fun1 string8 db 'The 8 Bit is 1$' string7 db 'The 7 Bit is 1$' string6 db 'The 6 Bit is 1$' string5 db 'The 5 Bit is 1$' string4 db 'The 4 Bit is 1$' string3 db 'The 3 Bit is 1$' string2 db 'The 2 Bit is 1$' string1 db 'The 1 Bit is 1$' data ends

assume ds:data,cs:code code segment start:

mov ax,data

mov ds,ax

mov bl,10h mov ax,0000h mov cx,8

math: shl bl,1 jc right

jmp next right:mov dl,02h mul dl

mov bp,ax jmp addres[bp] next: inc ax loop math

fun8:mov dx,offset string8

cout:mov ah,09h

int 21h mov ah,4ch int 21h

jmp cout jmp cout jmp cout jmp cout jmp cout jmp cout jmp cout jmp cout

fun7:mov dx,offset string7 fun6:mov dx,offset string6 fun5:mov dx,offset string5 fun4:mov dx,offset string4 fun3:mov dx,offset string3 fun2:mov dx,offset string2 fun1:mov dx,offset string1

code ends end start

2. 编写一个子程序计算z=f(x,y)=x*y+x-y(x,y,z有符号数内存数)。要求通过堆栈(寄存器、内存)传送所有参数。

使用堆栈: data segment x db 03h y db 0ffh z dw 0000h data ends stack segment dw 100 dup(?)

stack ends

assume ds:data,cs:code,ss:stack code segment start: mov ax,data mov ds,ax

mov ax,stack mov ss,ax mov al,x push ax mov al,y push ax call program mov z,dx add sp,2 jmp quit

program: push bp mov bp,sp

mov ax,[bp+6] mov dx,[bp+4] imul dl mov dx,ax mov ax,[bp+6]

cbw add dx,ax mov ax,[bp+4] cbw sub dx,ax pop bp ret

mov ah,4ch

quit:

int 21h

code ends end start

二、使用寄存器传值

data segment x db 03h y db 0ffh z dw 0000h data ends stack segment dw 100 dup(?)

stack ends

assume ds:data,cs:code,ss:stack code segment start: mov ax,data mov ds,ax

mov ax,stack mov ss,ax mov al,x mov bl,y call program mov z,dx jmp quit

program:

合肥工业大学汇编程序设计实验报告完整代码.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c5fog51r5es7zlrl1b2zo_4.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top