微机实验报告
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
微机实验报告
第⼀次实验
1.写出完成下列功能的指令序列
(1)传送20H到AL寄存器MOV AL , 20H
(2)将(AL)*2 MOV AL , 02H MUL AL (3)传送25H到BL寄存器MOV BL , 25H (4)(AL)*BL MUL BL
问最后结果(AX)=?
AX=0940H
2.分别写出完成下列指令要求的指令
(1)将BX的低4位清零AND BX , F0H
(2)将AX的⾼4位置1 OR AX , F0H
(3)将DX的低4位取反;XOR DX , 0FH
(4)将CX的中间⼋位清零AND CX , 0FF0H
(5)将AX中与BX中的对应位不相同的位均置1 XOR AX , BX
3.上机运⾏下⾯指令序列,分析运⾏后(AX)=?
mov cl , 8
sar ax ,cl
dec ax
mov cx ,8
mul cx
ax=210.9h
4. 4.设DS=当前段地址,BX=0300H,SI=0002H,请⽤DEBUG的命令将存储器偏移地址300-304H连续单元装⼊0AH0BH0CH0DH0EH。
在DEBUG状态下送⼊下⾯的程序,并⽤单步执⾏的⽅法,分析每条指令原源地址的形成过程?当数据传送完毕时,AX中的内容是什么?
8.编程:求两个数的平均值。
这两个数分别放在X单元和Y单元中,⽽平均值放在Z单元中。
即Z=(X+Y)/2 data segment
x db 2
y db 6
z db ?
data ends
code segment
assume cs:code, ds;data
start:
mov ax, data
mov ds,ax
mov al, x
mov ah,0
add al,y
mov bl,2
div bl
int 21h
code ends
end start
9.输⼊下⾯源程序,并对程序进⾏会变,连接,调式并说明程序的功能。
data segment number dw 0168h
data ends
code segment
assume cs;code, ds: data
org 0100h
start:
mov ax, data
mov ds, ax
mov dx,0
mov bx, 0001h
mov di, 8000h
mov si, 0
mov ax, number
mov cx, 16
next;
test ax, bx
jz continue
or dx, di
inc si
continue:
ror di, 1
mov ah,4ch
int 21h
code ends
end start
1.编写程序: 求1+2+3+…..+100的和data segment number db 01h
data ends
code segment
assume cs:code , ds:data
start:
mov ax , data
mov ds , ax
mov ax , data
mov bx , number
mov ax , 0
mov cx , 64h
next:
add ax ,bx
inc bx
loop next
mov ah , 4ch
int 21h
code ends
end start
2.在内存中tab为⾸的地⽅存有1-9的平⽅值,从键盘输⼊⼀个数(1-9),将该数存⼊X单元,⽴⽅值存⼊XXX单元中data segment
tab db 0,1,4,9,16,25,36,49,64,81
x db 10dup(?)
xxx db 10dup(?)
data ends
code segment
assume cs:code ,ds: data
start:
mov ax ,data
mov ds , ax mov ax , data
mov cx ,09h
next:
mov ah , 1
int 21h
and ah ,0fh
mov bx ,ah
mov si , offset tab
mov sp , offset x
mov di , offset xxx
mov dx , byte ptr[bx+si]
mov al, bl
mul dx
mov [bx+di] ,ax
mov [sp+bx] , bx
mov ah , 4ch
int 21h
code ends
end start
第⼆次实验
顺序程序设计
从键盘输⼊两个1位⼗进制数,求这两个数的和,并将结果显⽰在屏幕上data segment infor1 db 'please input the first data (<10):$'
infor2 db 0ah,0dh,'please input the second data (<10):$'
infor3 db 0ah,0dh,'the result is:$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset infor1
mov ah,9
int 21h
mov ah,1
int 21h
and al,0fh
mov ah,00000000000000000000
mov bl,al
mov dx,offset infor2
int 21h
mov ah,1
int 21h
and ax,000fh
add al,bl
aaa
or ax,3030h
push ax
mov dx,offset infor3 mov ah,9
int 21h
pop ax
mov dl,ah
push ax
mov ah,2
int 21h
pop ax
mov dl,al
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start
result db 0ah,0dh,'cube result is :$' data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov dx,offset number
mov ah,9
int 21h
mov ah,1
int 21h
and ax,000fh
mov bx,ax
mul bl
mul bl
mov cl,64h
div cl
or al,30h
push ax
mov dx,offset result
mov ah,9
int 21h
pop ax
mov dl,al
push ax
mov ah,2
int 21h
pop ax
mov cl,0ah
mov al,ah
mov ah,0
div cl
or ax,3030h
push ax
mov ah,2
int 21h
pop ax
mov dl,ah
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start
分⽀程序设计
1.某程序可从键盘接收命令(0-5),分别专项6个⼦程序,⼦程序⼊⼝地址分别为p0-p5,编制程序,⽤跳转表实现分⽀结构程序设计,记录实验结果
data segment
message db 'please input key (0-5):$'
crmessage db 0ah,0dh,'$'
errormessage db 'you hit error key !',0ah,0dh
db 'please try again(0-5):$'
message0 db 'you hit the key 0',0ah,0dh,'$'
message1 db 'you hit the key 1',0ah,0dh,'$'
message2 db 'you hit the key 2',0ah,0dh,'$'
message3 db 'you hit the key 3',0ah,0dh,'$'
message4 db 'you hit the key 4',0ah,0dh,'$'
message5 db 'you hit the key 5',0ah,0dh,'$'
code segment
assume cs:code,ds:data start:
mov ax,data
mov ds,ax
mov ah,9
lea dx,message
int 21h
tryagain:
mov ah,1
int 21h
mov bl,al
mov ah,9
mov dx,offset crmessage int 21h
cmp bl,'0'
jz key0
cmp bl,'1'
jz key1
cmp bl,'2'
jz key2
cmp bl,'3'
jz key3
cmp bl,'4'
jz key4
cmp bl,'5'
jz key5
error:
mov ah,9
mov dx,offset errormessage int 21h
jmp tryagain
key0:
lea dx,message0
mov ah,9
int 21h
jmp exit
key1:
lea dx,message1 mov ah,9
int 21h
jmp exit
key2:
lea dx,message2 mov ah,9
int 21h
jmp exit
key3:
lea dx,message3 mov ah,9
int 21h
jmp exit
key4:
lea dx,message4 mov ah,9
int 21h
jmp exit
key5:
lea dx,message5 mov ah,9
int 21h
exit:
mov ah,4ch
int 21h
code ends
end start
第三次实验
循环程序设计
1.从⾃然数1开始累加,直到累加和⼤于1000为⽌,统计被累加的⾃然数的个数,并把统计的个数送⼊N单元,把累加和送⼊SUM单元。
data segment
n dw ?
sum dw ?
x db 'n is :$'
y db 0Ah,0Dh,'sum is :$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ah,9
mov dx,offset x
int 21h
mov ax,0
mov bx,0
mov cx,0
mov dx,0
again:
add bx,1
add ax,bx
add cx,1
cmp ax,3e8h
jbe again
mov n,cx
mov sum,ax
mov si,ax
mov ax,cx
mov bl,10
div bl
mov bh,ah
mov dl,al
call zg
mov dl,bh
call zg
mov ah,9
mov dx,offset y
int 21h
mov ax,si
mov dx,0
mov bx,1000 div bx
mov bx,dx mov dl,al call zg
mov ax,bx mov bl,100 div bl
mov bh,ah mov dl,al call m
mov al,bh mov ah,0 mov bl,10 div bl mov bh,ah mov dl,al call zg
mov dl,bh call zg
mov ah,4ch int 21h
zg proc
or dl,30h mov ah,2
int 21h
ret
m endp code ends end start
⼦程序设计
2.编制计算n个(n<=50续偶数之和(2+4+6...)的程序。
data segment buf db 10
db ?
db 10 dup(?)
data ends
code segment
main proc far
assume cs:code ,ds:data
start:
mov ax,data
mov ds,ax
mov ah,0ah
mov dx,offset buf
int 21h
mov cl,buf+1
mov ch,0
mov si,offset buf+2
mov ax,0
again:
mov bl,10
mul bl
sub byte ptr [si],30h
add al,[si]
adc ah,0
loop again call qh
call xs
mov ah,4ch int 21h
ret
main endp qh proc near mov cx,ax mov ax,0 mov dx,0 again1:
add dx,2 add ax,dx loop again1 ret
qh endp
xs proc near mov dx,0 mov bx,1000 div bx
mov bx,dx mov dl,al call p
mov ax,bx mov bl,100 div bl
mov bh,ah mov dl,al call p
mov al,bh mov ah,0 mov bl,10 div bl
mov bh,ah mov dl,al call p
mov dl,bh call p
ret
p proc near
or dl,30h
mov ah,2
int 21h
ret
p endp
code ends
end start
第四次实验
PC机内部8259中断实验
编写中断处理程序,要求主程序运⾏时,设10秒响⼀次。
同时屏幕上显⽰信息“the bell is ring!”data segment
count dw 1
mess db 'the bell is ring!',0dh,0ah,'$'
data ends
stack segment
db 100 dup (?)
stack ends
code segment
main proc far
assume cs:code,ds:data,ss:stack
mov ax,stack mov ss,ax
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov al,1ch
mov ah,35h
int 21h
push es
push bx
push ds
mov dx,offset ring mov ax,seg ring mov ds,ax mov al,1ch
mov ah,25h
int 21h
pop ds
mov al,10110110b out 43h,al
mov ax,533h
out 42h, al
mov al,ah
out 42h,al
in al,21h
and al,0feh
out 21h,al
sti
d:
mov ah,0
int 16h
cmp al,1bh
jnz d
pop dx
pop ds
mov al,1ch
mov ah,25h
int 21h
main endp
ring proc near push ds
push ax
push cx
push dx
mov ax,data
mov ds,ax
sti
dec count
jnz exit
mov dx,offset mess mov ah,09 int 21h
mov dx,2000h
in al,61h
and al,0fch sound:
xor al,03h
out 61h,al
mov cx,9600h wait1:
loop wait1
dec dx
jnz sound
mov count,91 exit:
cli
pop dx
pop cx
pop ax pop ds iret
ring endp code ends end start。