80C196单片机鼠标接口程序设计实例
ANDBINT_MASK,#0BFH
LDBAL,LRB_OK;取鼠标信息
LDBX,M_X
LDDX,M_Y
ORBINT_MASK,#40H
RET
;
;清单三:串口中断服务程序
SIOINT:PUSHF;中断服务
PUSHAX
LDBAL,SBUF
LDBAH,SP_STAT
JBSAL,6,ISB0;第一个字节
CMPM_P,#M_BUF
JNESIO_1
SJMPC99;缓冲区空,出错
SIO_1:CMPM_P,#M_BUF+2
JHC98;缓冲区满,出错
STBAL,[M_P]+;存储收到字节
CMPM_P,#M_BUF+3
JNEC99
LDM_P,#M_BUF;已收到完整命令
GOLR:LDBAL,1[M_P];处理X方向位移
SHLBAL,#2
EXTBAL
SHRAAX,#2
ADDM_X,AX
CKL:CMPM_X,#0
JGECKR
CLRM_X
CKR:CMPM_X,#SCRNW
JLTGOUD
LDM_X,#SCRNW
GOUD:LDBAL,2[M_P];处理Y方向位数
SHLBAL,#2
EXTBAL
SHRAAX,#2
ADDM_Y,AX
CKU:CMPM_Y,#0
JGECKD
CLRM_Y
CKD:CMPM_Y,#SCRNH
JLTELRUD
LDM_Y,#SCRNH
ELRUD:SJMPC98
ISB0:STBAL,M_BUF
ANDBAL,#0FH
CMPBAL,#03H
JEC97;=X3H,
CMPBAL,#0CH
JEC97;=XCH
CMPBAL,#0DH
JNEC98;<>XDH
ORBLRB_OK,#80H;确认鼠标正常
C97:ANDBAL,M_BUF,#30H
ANDBLRB_OK,#80H
ORBLRB_OK,AL;更新左右键状态
LDM_P,#M_BUF+1
SJMPC99
C98:LDM_P,#0000H
C99:POPAX
POPF
《80C196单片机鼠标接口程序设计实例(第4页)》
本文链接地址:http://www.oyaya.net/fanwen/view/175620.html
LDBAL,LRB_OK;取鼠标信息
LDBX,M_X
LDDX,M_Y
ORBINT_MASK,#40H
RET
;
;清单三:串口中断服务程序
SIOINT:PUSHF;中断服务
PUSHAX
LDBAL,SBUF
LDBAH,SP_STAT
JBSAL,6,ISB0;第一个字节
CMPM_P,#M_BUF
JNESIO_1
SJMPC99;缓冲区空,出错
SIO_1:CMPM_P,#M_BUF+2
JHC98;缓冲区满,出错
STBAL,[M_P]+;存储收到字节
CMPM_P,#M_BUF+3
JNEC99
LDM_P,#M_BUF;已收到完整命令
GOLR:LDBAL,1[M_P];处理X方向位移
SHLBAL,#2
EXTBAL
SHRAAX,#2
ADDM_X,AX
CKL:CMPM_X,#0
JGECKR
CLRM_X
CKR:CMPM_X,#SCRNW
JLTGOUD
LDM_X,#SCRNW
GOUD:LDBAL,2[M_P];处理Y方向位数
SHLBAL,#2
EXTBAL
SHRAAX,#2
ADDM_Y,AX
CKU:CMPM_Y,#0
JGECKD
CLRM_Y
CKD:CMPM_Y,#SCRNH
JLTELRUD
LDM_Y,#SCRNH
ELRUD:SJMPC98
ISB0:STBAL,M_BUF
ANDBAL,#0FH
CMPBAL,#03H
JEC97;=X3H,
CMPBAL,#0CH
JEC97;=XCH
CMPBAL,#0DH
JNEC98;<>XDH
ORBLRB_OK,#80H;确认鼠标正常
C97:ANDBAL,M_BUF,#30H
ANDBLRB_OK,#80H
ORBLRB_OK,AL;更新左右键状态
LDM_P,#M_BUF+1
SJMPC99
C98:LDM_P,#0000H
C99:POPAX
POPF
《80C196单片机鼠标接口程序设计实例(第4页)》