出租车计价器.docx

上传人:b****7 文档编号:10767955 上传时间:2023-02-22 格式:DOCX 页数:25 大小:18.35KB
下载 相关 举报
出租车计价器.docx_第1页
第1页 / 共25页
出租车计价器.docx_第2页
第2页 / 共25页
出租车计价器.docx_第3页
第3页 / 共25页
出租车计价器.docx_第4页
第4页 / 共25页
出租车计价器.docx_第5页
第5页 / 共25页
点击查看更多>>
下载资源
资源描述

出租车计价器.docx

《出租车计价器.docx》由会员分享,可在线阅读,更多相关《出租车计价器.docx(25页珍藏版)》请在冰豆网上搜索。

出租车计价器.docx

出租车计价器

cursormacrorow,clm;***********移动光标位置到(row,clm)*******************io8255c第三口接LED灯用来表示行车等待

pushax

pushbx

pushdx

movah,2

movbh,0

movdh,row

movdl,clm

int10h

popdx

popbx

popax

endm

datasegment

ioportequ0b800h-0280h

io8253aequioport+280h;8253计数器0地址

io8253bequioport+281h;8253计数器1地址

io8253cequioport+282h;8253计数器2地址

io8253dequioport+283h;8253控制寄存器地址

io8255aequioport+288h;8255A口地址

io8255cequioport+28ah;8255C口地址

io8255bequioport+289h;

io8255dequioport+28bh;8255控制寄存器地址

onekmequ100;一公里对应的脉冲数

waitnumequ50;参考脉冲数,小于此值即为等待

startpequ80;起步价8元

pricedb24;行车计费,2.4元/公里

waitpequ2;等待计费,0.2元/分钟

str0db'',0dh,0ah,'$'

str1db'**************************Taximeter*************************',0dh,0ah,'$'

str6db'****************************',0dh,0ah,'$'

str2db'*********PRICE:

2.40yuan/km0.2yuan/min***************',0dh,0ah,'$'

str12db'*********PRICE:

1.20yuan/km0.2yuan/min***************',0dh,0ah,'$'

str3db'TIME:

0(M)',0dh,0ah,'$'

str4db'DIST:

0(KM)',0dh,0ah,'$'

str5db'COST:

0(YUAN)',0dh,0ah,'$'

str7db'Fivecost:

',0dh,0ah,'$'

str8db'PRESSSTOSTART',0dh,0ah,'$'

str9db'PRESSOTOSTOP',0dh,0ah,'$'

str10db'PRESSQTOEXIT',0dh,0ah,'$'

str11db'GETOFFTHETAXIend_time:

00:

00:

00',0dh,0ah,'$'

str14db'start_time:

00:

00:

00',0dh,0ah,'$'

pnumdw0;总脉冲数

distdb0;总里程

timedb0;等待时间

totaldw0000h;总费用

flagdb11h

xdkdb0

feeBufferdw0000h,0000h,0000h,0000h,0000h

feeCountdb0

leddb3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh;段码

buffer1db6,5h;存放要显示的个位和十位

bzdw?

;位码

dataends

stackssegmentstack

db100dup(?

stacksends

codesegment

assumecs:

code,ds:

data,ss:

stacks

mainproc

start:

movax,data

movds,ax

movax,stacks

movss,ax

movdx,io8255a

inal,dx

testal,04h;00000100

jzbb

movbl,55h

movflag,bl

movbl,12

movprice,bl

bb:

callini;调用初始化子程序

calldisp

begin1:

movdi,offsetbuffer1;设di为显示缓冲区

calllll;

movdx,io8255a

inal,dx

testal,02h

jnzexit;

testal,01h;判断是否有1秒钟定时中断信号,1为start启动

jzbegin1

callbegin

;testal,00000000b

movbx,total

moval,bl

callextendBcd

movwordptr[buffer1],ax

movdx,io8255a

inal,dx

testal,00001000b

jzshowl1

moval,dist

callextendBcd

movwordptr[buffer1],ax

jmpshowl3

showl1:

movdx,io8255a

inal,dx

testal,00010000b

jzshowl2

moval,time

callextendBcd

movwordptr[buffer1],ax

jmpshowl3

showl2:

movdx,io8255a

inal,dx

testal,00100000b

jzshowl3

movbx,total

moval,bh

callextendBcd

movwordptr[buffer1],ax

showl3:

movdx,io8255a

inal,dx

andal,10000000b;判断是否有1秒钟定时中断信号

jzbegin1

callgains

movbl,feeCount

cmpbl,9

jaaboveCount

jmpbelowCount

aboveCount:

movbl,0

belowCount:

movax,total

movbh,0

movfeeBuffer[bx],ax

incbl

incbl

movfeeCount,bl

jmpbegin1

exit:

calloff_texi

cursor11,0

movah,4ch;退出程序

int21h

mainendp

extendBcdproc

pushbx

pushcx

movbl,al

movcl,4

shral,cl

movah,al

andbl,00001111b

moval,bl

popcx

popbx

ret

extendBcdendp

lllproc

pushdi

pushbx

pushax

pushsi

movbh,2

ll:

movbyteptrbz,bh;数码管显示程序

pushdi

decdi

adddi,bz

movbl,[di];bl为要显示的数

popdi

moval,0

movdx,io8255c;消隐,全部关闭

outdx,al

movbh,0

movsi,offsetled;置led数码表偏移地址为SI

addsi,bx;求出对应的led数码

moval,byteptr[si]

movdx,io8255b;自8255B的口输出

outdx,al

moval,byteptrbz;使相应的数码管亮

oral,xdk

movdx,io8255c

outdx,al

movcx,3000

delay:

loopdelay;延时

movbh,byteptrbz

shrbh,1

jnzll

popsi

popax

popbx

popdi

ret

lllendp

gainsproc;计价更新程序

pushax

pushbx

pushcx

pushdx

movax,total

andax,ax

jzreturn2

movdx,io8253c;读取脉冲数

inal,dx

movbl,al

movdx,io8253a;计数器0重新计数

movax,1000

outdx,al

moval,ah

outdx,al

movdx,io8253b

movax,1000;计数器1重新计数

outdx,al

moval,ah

outdx,al

moval,0

movdx,io8253c;计数器2重新计数

outdx,al

moval,0ffh;计算脉冲数

subal,bl

incal

cmpal,waitnum;脉冲数小于参考值则为等待状态,否则为行车状态

jbwgain

movah,00000100b

movxdk,ah

movah,0

addpnum,ax

movax,pnum

movbl,100

divbl

callnum2bcds;计算行驶里程数并转化为2位压缩BCD码

movdist,al

jmpnewcost

wgain:

moval,0

movxdk,al

moval,time;判断为等待状态,等待时间加1

callbcd2num

incal

callnum2bcds

movtime,al

jmpnewcost

return2:

jmpreturn

newcost:

moval,dist;计算当前总金额

callbcd2num

movtotal,startp

cmpal,3

jbecost2

subal,3

movah,0

movbl,price

mulbl

addtotal,ax

cost2:

moval,time

callbcd2num

movah,0

movbl,waitp

mulbl

addax,total

callnum2bcdl

movtotal,ax

calldisp

return:

popdx

popcx

popbx

popax

ret

gainsendp

;*********************2位压缩BCD码转换为十进制数***************************

bcd2numproc

pushbx

pushcx

movbh,al

movcl,4

shral,cl

movbl,10

mulbl

andbh,00001111b

addal,bh

popbx

popcx

ret

bcd2numendp

commaproc

pushax

pushdx

movah,2

movdl,'.'

int21h

popdx

popax

ret

commaendp

;*********************************显示程序*******************************

showproc

callshow1

cmpdl,1

jnzdown

callcomma

down:

callshow11

ret

showendp

;****************************显示子程序1*************************************

show1proc

pushdx

pushcx

pushax

movdl,al

movcl,4

shrdl,cl

adddl,30h

movah,02h

int21h

popax

popcx

popdx

ret

show1endp

;**************************显示子程序2***********************************

show11proc

pushdx

pushax

movdl,al

anddl,00001111b

adddl,30h

movah,02h

int21h

popax

popdx

ret

show11endp

;***************************数值更新显示程序*******************************

dispproc

pushax

pushbx

pushdx

pushsi

movdl,0

cursor3,6

moval,time

callshow

movdl,0

cursor4,6

moval,dist

callshow

movdl,0

cursor5,6

movbx,total

moval,bh

callshow

movdl,1

moval,bl

callshow

movsi,0

;movdh,1

;lopp:

movdl,0

cursor7,12

movbx,feeBuffer[si]

moval,bh

callshow

movdl,1

moval,bl

callshow

;1

incsi

incsi

movdl,0

cursor7,21

movbx,feeBuffer[si]

moval,bh

callshow

movdl,1

moval,bl

callshow

;2

incsi

incsi

movdl,0

cursor7,30

movbx,feeBuffer[si]

moval,bh

callshow

movdl,1

moval,bl

callshow

;3

incsi

incsi

movdl,0

cursor7,39

movbx,feeBuffer[si]

moval,bh

callshow

movdl,1

moval,bl

callshow

;4

incsi

incsi

movdl,0

cursor7,48

movbx,feeBuffer[si]

moval,bh

callshow

movdl,1

moval,bl

callshow

;5

;loppend

popsi

popdx

popbx

popax

ret

dispendp

;*********************************8位二进制码转2位压缩BCD码**************************

num2bcdsproc

pushbx

pushcx

pushdx

cmpal,9

jbe_out1

movah,0

movbl,10

divbl

cmpal,10

jaeerror1

movcl,4

shlal,cl

andah,0fh

addal,ah

_out1:

popdx

popcx

popbx

ret

error1:

cursor11,0

movsi,offsetstr7

movdx,si

movah,09h

int21h

movah,4ch

int21h

num2bcdsendp

;*********************************16位二进制码转4位压缩BCD码****************************

num2bcdlproc

pushbx

pushcx

pushdx

cmpax,9999

jaerror2

cmpax,0009h

jbe_out2

movdx,ax

movbl,100

divbl

movbh,ah

callnum2bcds

movbl,al

moval,bh

callnum2bcds

movah,bl

_out2:

popdx

popcx

popbx

ret

error2:

cursor11,0

movsi,offsetstr7

movdx,si

movah,09h

int21h

movah,4ch

int21h

num2bcdlendp

;*****************************************初始化程序**********************************

iniproc

pushax

pushdx

pushsi

movbh,7

movdx,314fh

movax,0600h

movcx,0

int10h;清屏幕

cursor0,0

movax,0

movpnum,ax

movdist,al

movtime,al

movtotal,ax;相关存储单元内容清零

movdx,io8255d

moval,10010000b;置8255工作方式为A口输入,C口输出

outdx,al

movdx,offsetstr1;在屏幕上显示提示语

movah,09h

int21h

movdx,offsetstr6

movah,09h

int21h

cmpflag,55h

jzbbb

movdx,offsetstr2

jmpbbbb

bbb:

movdx,offsetstr12

bbbb:

movah,09h

int21h

movdx,offsetstr3

movah,09h

int21h

movdx,offsetstr4

movah,09h

int21h

movdx,offsetstr5

movah,09h

int21h

movdx,offsetstr14

movah,09h

int21h

movdx,offsetstr7

movah,09h

int21h

popsi

popdx

popax

ret

iniendp

;*********************************启动计费******************************************

beginproc

pushax

pushbx

pushcx

pushdx

movax,total

andax,ax

jnzrettt

;*********************************get_start_time*******************************************

movah,2ch

int21h

movdl,0

moval,ch

callnum2bcds

cursor6,11

callshow

moval,cl

callnum2bcds

cursor6,14

callshow

moval,dh

callnum2bcds

cursor6,17

callshow

;*****************************************************************************************

cursor11,0

movdx,offsetstr0

movah,09

int21h

moval,startp

callnum2bcds

movah,0

movtotal,ax;置总金额为起步价

jmpini_hard

rettt:

jmprett

ini_hard:

movdx,io8253d

moval,36h;置8253计数器0为方式3计数,初值1000

outdx,al

moval,70h;置8253计数器1为方式0计数,初值1000,计数器0与1级联计数产生1s定时

outdx,al

moval,90h;置8253计数器2为方式0计数,只计低字节

outdx,al

movax,1000

movdx,io8253a

outdx,al

moval,ah

outdx,al

movax,1000

movdx,io8253b

outdx,al

moval,ah

outdx,al

movdx,io8253c

moval,0

outdx,al

calldisp

rett:

popdx

popcx

popbx

popax

ret

beginendp

;******************************

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 中医中药

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1