简单计算器8086汇编代码Word文档格式.docx
- 文档编号:17489896
- 上传时间:2022-12-06
- 格式:DOCX
- 页数:21
- 大小:18.02KB
简单计算器8086汇编代码Word文档格式.docx
《简单计算器8086汇编代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《简单计算器8086汇编代码Word文档格式.docx(21页珍藏版)》请在冰豆网上搜索。
******************************************
8086系列微机接口实验系统 软件实验项目
键盘扫描显示实验
INITMACRONAME
movNAME+0,0ffh
movNAME+1,0c0h
movNAME+2,0ffh
movNAME+3,0ffh
movNAME+4,0ffh
movNAME+5,0ffh
ENDM
codesegment
assumecs:
code
OUTSEGequ0ffdch;
段控制口
OUTBITequ0ffddh;
位控制口/键扫口
IN_KEYequ0ffdeh;
键盘读入口
LedBufdb10dup(?
);
显示缓冲
Storedb10dup(?
存放显示第一组数据
numdb10dup(?
)
Store1db10dup(?
用于存放第一组数据
num1db10dup(?
用于存放第二组数据
flagdb0;
作为标记位,若为1代表加为0代表减
tempdb0
jinweidb0
jieweidb0
in_flagdb0
Key_Buffdb30dup(?
用于键盘输入的存储
org1000h
Start:
INITStore
INITnum
INITLedBuf
movsi,-1;
设置数组的下标
movStore1+0,0
movStore1+1,0
movStore1+2,0
movStore1+3,0
movStore1+4,0
movnum1+0,0
movnum1+1,0
movnum1+2,0
movnum1+3,0
movnum1+4,0
MLoop:
callDisp;
显示
callGetKey;
扫描键盘并读取键值
cmpal,20h
jeLL
jmpLL1
LL:
movtemp,0
jmpMLoop
LL1:
pushdx
movdl,temp
movtemp,1
cmpal,09h
jatransmit
cmpKey_Buff[si],al
jzinkey_flag
jmpLL2
inkey_flag:
cmptemp,dl
popdx
jzMLoop
jmpLL2;
!
注意要加这一句
transmit:
jmpSPECIAL;
特殊字符特殊处理
LL2:
incsi
movKey_Buff[si],al;
将键盘输入的键盘码放到Key_Buff中
cmpsi,5
jaeabc
movdl,Store1+1
movStore1+0,dl
movdl,Store1+2
movStore1+1,dl
movdl,Store1+3
movStore1+2,dl
movdl,Store1+4
movStore1+3,dl
movStore1+4,al
jmpbcd
abc:
movdi,si
subdi,5
movdl,num1+1
movnum1+0,dl
movdl,num1+2
movnum1+1,dl
movdl,num1+3
movnum1+2,dl
movdl,num1+4
movnum1+3,dl
movnum1+4,al
bcd:
andal,0fh;
显示键码
movah,0
movbx,offsetLEDMAP
addbx,ax
moval,[bx]
jaenext1
movStore[si+1],al
jmpback1
next1:
movnum[di+1],al
jmpstart1
back1:
pushdx;
将Store里的数据放到Led中,方便以后显示
movdl,Store+1
movLedBuf+1,dl
movdl,Store+2
movLedBuf+2,dl
movdl,Store+3
movLedBuf+3,dl
movdl,Store+4
movLedBuf+4,dl
movdl,Store+5
movLedBuf+5,dl
start1:
callDisp
;
jmpMLoop
back2:
movdl,num+1
movdl,num+2
movdl,num+3
movdl,num+4
movdl,num+5
back3:
movdl,Store+0
movLedBuf+0,dl
SPECIAL:
cmpal,0ah
jnedecre
movflag,1
movsi,4
decre:
cmpal,0bh
jneRestart
movflag,0
Restart:
cmpal,0ch
jneExit
jmpStart
Exit:
cmpal,0eh
jneDisplay
movStore+0,0Ch;
显示"
P"
movStore+1,0ffh
Display:
cmpal,0dh
jeprint
jmpback3
print:
cmpflag,0
jesubb
jmpadda
subb:
movcl,num1+0;
比较两数大小,如果用小数减大数则交换数据
movbl,Store1+0
cmpbl,cl
jbjiaoh
movcl,num1+1
movbl,Store1+1
movcl,num1+2
movbl,Store1+2
movcl,num1+3
movbl,Store1+3
movcl,num1+4
movbl,Store1+4
jmpjianfa
jiaoh:
交换两个数组中的数值
movdh,num1+0
movdl,Store1+0
movStore1+0,dh
movdh,num1+1
movStore1+1,dh
movdh,num1+2
movStore1+2,dh
movdh,num1+3
movStore1+3,dh
movdh,num1+4
movnum1+4,dl
movStore1+4,dh
movStore[0],0BFh;
最高位显示“-”
jianfa:
movcl,num1+4;
最低位相减
jaeH1
movjiewei,1
movbh,0ah
subbh,cl
addbl,bh
movcl,bl
jmpF1
H1:
subbl,cl
F1:
moval,cl
movStore[5],al
movcl,num1+3;
第二位相减
subbl,jiewei
cmpbl,0Fh;
考虑0被借位变成F
jzN1
jmpM1
N1:
movbl,09h
M1:
movjiewei,0
jaeH2
jmpF2
H2:
F2:
movStore[4],al
movcl,num1+2;
第三位相减
jzN2
jmpM2
N2:
M2:
jaeH3
jmpF3
H3:
F3:
movStore[3],al
movcl,num1+1;
第四位相减
jzN3
jmpM3
N3:
M3:
jaeH4
jmpF4
H4:
F4:
movStore[2],al
最高位相减
jaeH5
subcl,bl
jmpF5
H5:
F5:
movStore[1],al
ADDa:
最低位执行加法
addcl,bl
cmpcl,0ah
jbH
subcl,0ah
incjinwei
H:
第二位加法
addcl,jinwei
movjinwei,0
jbHA
HA:
第三位执行加法
jbHB
HB:
执行加法
jbHC
HC:
最高位执行加法
jaecontinue
continue:
movStore[0],8Eh
movStore[1],8Eh
movStore[2],8Eh
movStore[3],8Eh
movStore[4],8Eh
movStore[5],8Eh
系统原有的函数直接调用
Disp:
movbx,offsetLEDBuf
movcl,6;
共6个八段管
movah,00100000b;
从左边开始显示
DLoop:
movdx,OUTBIT
moval,0
outdx,al;
关所有八段管
movdx,OUTSEG
outdx,al
moval,ah
显示一位八段管
pushax
movah,1
callDelay
popax
shrah,1
incbx
deccl
jnzDLoop
ret
Delay:
延时子程序
pushcx
movcx,256
loop$
popcx
GetKey:
键扫子程序
moval,0ffh;
关显示口
movbl,0
movah,0feh
movcx,8
key1:
shlal,1
movah,al
nop
movdx,IN_KEY
inal,dx
notal
andal,0fh
jnzkey2
incbl
loopkey1
nkey:
moval,20h
key2:
testal,1
jekey3
jmpkey6
key3:
testal,2
jekey4
moval,8
key4:
testal,4
jekey5
moval,10h
key5:
testal,8
jenkey
moval,18h
key6:
addal,bl
cmpal,10h
jncfkey
movbx,offsetKeyTable
xlat
fkey:
LedMap:
八段管显示码
db0c0h,0f9h,0a4h,0b0h,099h,092h,082h,0f8h
db080h,090h,088h,083h,0c6h,0a1h,086h,08eh
KeyTable:
键码定义
db07h,04h,08h,05h,09h,06h,0ah,0bh
db01h,00h,02h,0fh,03h,0eh,0ch,0dh
codeends
endStart
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 计算器 8086 汇编 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)