计算机原理课程设计.docx
《计算机原理课程设计.docx》由会员分享,可在线阅读,更多相关《计算机原理课程设计.docx(32页珍藏版)》请在冰豆网上搜索。
计算机原理课程设计
成绩:
大连理工大学
本科实验报告
课程名称:
计算机原理课程设计
学院(系):
电子与信息工程学院
专业:
电子信息工程
班级:
学号:
学生姓名:
辅导教师:
2008.12.26
目录
一运算类程序设计编程训练
二循环程序设计编程训练
三排序程序设计编程训练
四8255并行接口实验
五8259中断实验
(一)
六8259中断实验
(二)
七8253定时/计数器实验
八A/D转换实验
九步进电机实验
十综合实验
十一实验体会
一运算类程序设计编程训练
用减奇数法开平方
DATASEGMENT
DADB64H,79H,90H
COUNTEQU($-DA)
PFGDBCOUNTDUP(0)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA
START:
MOVAX,DATA
MOVDS,AX
MOVCX,COUNT
MOVSI,OFFSETDA
MOVDI,OFFSETPFG
LOP:
MOVAL,[SI]
SQR_PROCPROC
MOVBL,0
MOVDL,1
SQR:
SUBAL,DL
JBEXIT
INCBL
ADDDL,2
JMPSQR
EXIT:
MOV[DI],BL
INCSI
INCDI
DECCX
JNZLOP
MOVAH,4CH
INT21H
SQR_PROCENDP
CODEENDS
ENDSTART
二循环程序设计编程训练
DATASEGMENT
DADB00H,01H,02H,0FDH,04H,10H,0FFH,0FEH,13H,14H
COUNTEQU($-DA)
PFGDB(COUNT+2)DUP(0)
DATAENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA
START:
MOVAX,DATA
MOVDS,AX
MOVCX,COUNT
MOVSI,OFFSETDA
MOVDI,OFFSETPFG
MOV[DI],CX
INCDI
MOVBL,0
MOVAH,7FH
LOP:
MOVAL,[SI]
MOV[DI],AL
CMPAL,AH
JNAL1
INCBL
L1:
INCSI
INCDI
DECCX
JNZLOP
MOV[DI],BL
MOVAH,4CH
INT21H
三排序程序设计编程训练
DATASEGMENT
BUFFERDW-100,300,500,200,400,900,1000,6000
COUNTEQU($-BUFFER)/2
DATAENDS
STACKSEGMENTSTACK
DB100DUP(?
)
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,DS:
DATA,SS:
STACK
MAINPROCFAR
START:
MOVAX,DATA
MOVDS,AX
MOVCX,COUNT-1
MAIN1:
LEABX,BUFFER
PUSHCX
MAIN2:
MOVAX,[BX]
INCBX
INCBX
CMPAX,[BX]
JLENEXT
XCHGAX,[BX]
MOV[BX-2],AX
NEXT:
LOOPMAIN2
POPCX
LOOPMAIN1
MOVAH,4CH
INT21H
MAINENDP
CODEENDS
ENDSTART
四8255并行接口实验
一,实验目的
1,学习利用并行接口芯片8255构成并行接口电路的基本方法。
2,熟悉掌握并行接口芯片8255的基本性能及在实际应用中硬件连接,初始化编程方法。
二,实验内容:
编写程序,使8255的PB口为输出口,PA口为输人口,从PA口将K0--K7作为一个字节读入,再从PB口输出这一反码字节。
三,实验程序:
CODESEGMENT
ASSUMECS:
CODE
START:
MOVDX,21BH
MOVAL,90H
OUTDX,AL
BG:
MOVDX,218H
INAL,DX
MOVDX,219H
OUTDX,AL
JMPBG
CODEENDS
ENDSTART
四,实验电路图
五8259中断实验
(一)
一,实验目的:
1,了解pc机的中断结构及8259中断控制器的初始化
2熟悉8259中断控制器的工作原理和硬件连线方法。
3,了解8259的应用和硬件编程方法
4,了解8259的中断屏蔽,以及优先级判别等特性。
5,了解8259的级联工作方式。
二,实验内容:
编写中断实验程序,主程序使8255的PB口为输出口,输出0FFH,L0—L7指示灯全亮,中断服务程序从PB口输出,L0—L3亮,L4—L7灭,并延时一段时间后返回主程序。
三,实验程序
INT0EQU220h
INT1EQU221h
INT10EQU228h
INT11EQU229h
STACKSEGMENT
STADB50DUP(?
)
TOPEQULENGTHSTA
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,SS:
STACK
START:
CLI
MOVAX,TOP
MOVSP,AX
pushds
MOVAX,0000H;SETIRQ0
MOVDS,AX
MOVAX,OFFSETIRQ0
ADDAX,0000H
MOVSI,20H
MOV[SI],AX
MOVAX,CS
MOVSI,22H
MOV[SI],AX
popds
MOVAL,13H;ICW1
MOVDX,INT0
OUTDX,AL
MOVAL,8;ICW2
MOVDX,INT1
OUTDX,AL
movcx,0fffh
loop$
MOVAL,9;ICW4
MOVDX,INT1
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT1
MOVAL,0FEH;OCW1
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT0
MOVAL,20H
OUTDX,AL
movcx,0fffh
loop$
MOVAL,13H;ICW1
MOVDX,INT10
OUTDX,AL
MOVAL,8;ICW2
MOVDX,INT11
OUTDX,AL
movcx,0fffh
loop$
MOVAL,9;ICW4
MOVDX,INT11
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT11
MOVAL,0FFH;OCW1
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT10
MOVAL,20H
OUTDX,AL
movcx,0fffh
loop$
STI
MOVDX,21BH
MOVAL,90H
OUTDX,AL
DSP:
MOVAL,0FFH
MOVDX,219H
OUTDX,AL
JMPDSP
IRQ0:
STI
movcx,0FFFFH
LOOP$
MOVAL,0FH
MOVDX,219H
OUTDX,AL
MOVDX,INT0
MOVAL,20H
OUTDX,AL
movcx,0FFFFH
LOOP$
movcx,0FFFFH
LOOP$
IRET
codeends
endstart
四,实验电路图
六8259中断实验
(二)
一,实验目的:
1,了解pc机的中断结构及8259中断控制器的初始化
2熟悉8259中断控制器的工作原理和硬件连线方法。
3了解8259的应用和硬件编程方法
4了解8259的中断屏蔽,以及优先级判别等特性。
5了解8259的级联工作方式。
二,实验内容
编写中断实验程序,主程序使8255的PB口为输出口,输出0FFH,L0—L7指示灯全亮,中断服务程序从PB口输出,L0—L3亮,L4—L7灭,并延时一段时间后返回主程序。
IR1中断服务程序从PB口输出0F0H,L0—L3灭,L4—L7亮,并延时一段时间后返回主程序。
三,实验程序
INT0EQU220h
INT1EQU221h
INT10EQU228h
INT11EQU229h
STACKSEGMENT
STADB50DUP(?
)
TOPEQULENGTHSTA
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,SS:
STACK
START:
CLI
MOVAX,TOP
MOVSP,AX
PUSHDS
MOVAX,0000H;SETIRQ0
MOVDS,AX
MOVAX,OFFSETIRQ0
ADDAX,0000H
MOVSI,20H
MOV[SI],AX
MOVAX,CS
MOVSI,22H
MOV[SI],AX
MOVAX,0000H;SETIRQ1
MOVDS,AX
MOVAX,OFFSETIRQ1
ADDAX,0000H
MOVSI,24H
MOV[SI],AX
MOVAX,CS
MOVSI,26H
MOV[SI],AX
POPDS
MOVAL,13H;ICW1
MOVDX,INT0
OUTDX,AL
MOVAL,8;ICW2
MOVDX,INT1
OUTDX,AL
movcx,0fffh
loop$
MOVAL,9;ICW4
MOVDX,INT1
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT1
MOVAL,0FCH;OCW1
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT0
MOVAL,20H;
OUTDX,AL
movcx,0fffh
loop$
MOVAL,13H;ICW1
MOVDX,INT10
OUTDX,AL
MOVAL,8;ICW2
MOVDX,INT11
OUTDX,AL
movcx,0fffh
loop$
MOVAL,9;ICW4
MOVDX,INT11
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT11
MOVAL,0FFH;OCW1
OUTDX,AL
movcx,0fffh
loop$
MOVDX,INT10
MOVAL,20H;
OUTDX,AL
movcx,0fffh
loop$
STI
MOVDX,21BH
MOVAL,90H
OUTDX,AL
DSP:
MOVAL,0FFH
MOVDX,219H
OUTDX,AL
JMPDSP
IRQ0:
STI
movcx,0FFFFH
LOOP$
MOVAL,0FH
MOVDX,219H
OUTDX,AL
MOVDX,INT0
MOVAL,20H
OUTDX,AL
movcx,0FFFFH
LOOP$
movcx,0FFFFH
LOOP$
IRET
IRQ1:
STI
movcx,0FFFFH
LOOP$
MOVAL,0F0H
MOVDX,219H
OUTDX,AL
MOVDX,INT0
MOVAL,20H
OUTDX,AL
movcx,0FFFFH
LOOP$
movcx,0FFFFH
LOOP$
IRET
codeends
endstart
四,实验电路
七8253定时/计数器实验
一,实验目的
1,了解定时器8253的初始化及用法。
2,会用逻辑笔或示波器观察8253的工作状态。
二,实验内容
编写程序,使8253的定时/计数器2工作在方式3下。
三,实验程序:
TIM_CTLEQU203H
TIMER0EQU200H
TIMER1EQU201H
TIMER2EQU202H
MODE23EQU0B6H
MODE13EQU76H
CODESEGMENT
ASSUMECS:
CODE
START:
TT:
CLI
MOVDX,TIM_CTL
MOVAL,MODE23
OUTDX,AL
MOVDX,TIMER2
MOVAL,0FFh
OUTDX,AL
MOVAL,0FFh
OUTDX,AL
WT:
JMPWT
CODEENDS
ENDSTART
四,实验电路
八A/D转换实验
一,实验目的
1,了解数/模转换的工作原理
2,掌握0809的使用方法
二,实验内容
编写程序,用0809的通道IN0采集数据并在数码管上显示。
三,实验程序
B8279EQU212H
D8279EQU210H
LED0EQU00
LED1EQU38H
datasegment
LEDDB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H
DB5EH,79H,71H
dataends
CODESEGMENT
ASSUMECS:
CODE,DS:
data
START:
MOVDX,B8279
MOVAL,0D0H
OUTDX,AL
MOVCX,0FFFFH
LOOP$
MOVDX,B8279
MOVAL,LED0
OUTDX,AL
MOVAL,LED1
OUTDX,AL
MOVDX,B8279
MOVAL,95H
OUTDX,AL
MOVDX,D8279
MOVAL,40H
OUTDX,AL
MOVDX,D8279
MOVAL,5eH
OUTDX,AL
MOVDX,D8279
MOVAL,77H
OUTDX,AL
TT:
MOVDX,230H
OUTDX,AL
MOVCX,0FFFFH
LOOP$
MOVDX,B8279
MOVAL,83H
OUTDX,AL
MOVDX,230H
INAL,DX
ANDAL,0FH
LEABX,LED
XLAT
MOVDX,D8279
OUTDX,AL
MOVDX,B8279
MOVAL,84H
OUTDX,AL
MOVDX,230H
INAL,DX
MOVCL,4H
RORAL,CL
ANDAL,0FH
LEABX,LED
XLAT
MOVDX,D8279
OUTDX,AL
jmpTT
CODEENDS
ENDSTART
四,实验电路
九步进电机实验
一,实验目的
1,了解步进电机的工作原理,以及脉冲分配概念。
2,掌握计算机控制步进电机的方法。
二,实验内容
编写程序,通过8255控制步进电机旋转。
三,实验程序
CODESEGMENT
ASSUMECS:
CODE
START:
MOVDX,21BH
MOVAL,90H
OUTDX,AL
BG:
MOVDX,218H
INAL,DX
CMPAL,01H
JNZC2
MOVBX,0FFFFH
JMPWORK
C2:
CMPAL,02H
JNZC4
MOVBX,07FFFH
JMPWORK
C4:
CMPAL,04H
JNZC8
MOVBX,0FFFH
JMPWORK
C8:
CMPAL,08H
JNZCC
MOVBX,07FFH
JMPWORK
CC:
MOVAL,00H
MOVDX,219H
OUTDX,AL
JMPBG
WORK:
MOVAL,01H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,03H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,02H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,06H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,04H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,0CH
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,08H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
MOVAL,09H
MOVDX,219H
OUTDX,AL
MOVCX,BX
LOOP$
JMPBG
CODEENDS
ENDSTART
四,实验电路
十综合实验
1电路图
2程序框图
3实验程序
tim_cequ203h
timer0equ200h
timer1equ201h
p8255kequ21bh
p8255bequ219h
int0equ220h
int1equ221h
STACKSEGMENT
STADB50DUP(?
)
TOPEQULENGTHSTA
STACKENDS
CODESEGMENT
ASSUMECS:
CODE,SS:
STACK
start:
CLI
movdx,p8255k
moval,90h
outdx,al
MOVAX,TOP
MOVSP,AX
pushds
MOVAX,0000H;SETIRQ0
MOVDS,AX
MOVAX,OFFSETIRQ0
ADDAX,0000H
MOVSI,20H
MOV[SI],AX
MOVAX,CS
MOVSI,22H
MOV[SI],AX
MOVAX,0000H;SETIRQ1
MOVDS,AX
MOVAX,OFFSETIRQ1
ADDAX,0000H
MOVSI,24H
MOV[SI],AX
MOVAX,CS
MOVSI,26H
MOV[SI],AX
MOVAX,0000H;SETIRQ2
MOVDS,AX
MOVAX,OFFSETIRQ2
ADDAX,0000H
MOVSI,28H
MOV[SI],AX
MOVAX,CS
MOVSI,2AH
MOV[SI],AX
popds
MOVAL,13H;ICW1
MOVDX,INT0
OUTDX,AL
MOVAL,8;ICW2
MOVDX,INT1
OUTDX,AL
MOVAL,9;ICW4
MOVDX,INT1
OUTDX,AL
MOVDX,INT1
MOVAL,0F8H;OCW1
OUTDX,AL
movdx,int0
moval,20h
outdx,al
movdx,tim_c
moval,36h;ji0mo3
outdx,al
moval,5ah;JICHUZHI
movdx,p8255b
outdx,al
pushax
movdx,timer0
moval,0
outdx,al
outdx,al
movdx,tim_c
moval,76h;ji1mo3
outdx,al
movdx,timer1;DUANDIANFANHUI
moval,5ah
outdx,al
moval,0
outdx,al
sti
popax
AA:
jmpAA
irq0:
sti
xoral,0ffh
pushax
movdx,p8255b
outdx,al
movdx,int0
moval,20h
outdx,al
popax
iret
irq1:
sti
xoral,0ffh
pushax
movdx,p8255b
outdx,al
movdx,int0
moval,20h
outdx,al
popax
iret
irq2:
sti
xoral,0ffh
pushax
moval,0f0h
movdx,p8255b
outdx,al
movdx,int0
moval,20h
outdx,al
popax
iret
codeends
endstart
4实验思想说明
5在实验中遇到的问题,怎样解决
十一实验体会
忽略此处..