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

发布时间 : 星期一 文章合肥工业大学汇编程序设计实验报告完整代码更新完毕开始阅读8b4e852cf524ccbff12184e4

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

一. 实验目的

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: