打印

哪位高手请指点一下

[复制链接]
1410|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
lixingde|  楼主 | 2008-10-16 23:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
   小弟现在在做多功能红外遥控器。
   下面是一段资料里的汇编程序,但我是从C51入门的,所以有些看得不大懂。还望哪位高手指点一下各段子程序的功能。
   程序清单
    伪定义:
            KEYX0   EQU   P1.0
            KEYX1   EQU   P1.1
            KEYX2   EQU   P1.2
            KEYX3   EQU   P1.3
            KEYY    EQU   P0
                 主 程 序 和 中 断 程 序 入 口
    ORG     0000H
    ORG     AJMP   START
    ORG     0003H
             RETI
    ORG     000BH
             RETI
    ORG     0013H
             RETI
    ORG     001BH
             LJMP   INTT1
    ORG     0023H
             RETI
    ORG     002BH
             RETI
                      初 始 化 程 序
CLEARMEMIO:  CLR   A 
             DEC   A   
             MOV   P0,A
             MOV   P1,A
             MOV   P2,A
             MOV   P3,A   
             CLR   P3.5  
CLEARMEM:    MOV   SP,#70H 
             MOV   IE,#00H  
             MOV   IP,#01H  
             MOV   TMOD,#22H 
             MOV   TH1,#0F3H 
             MOV   TL1,#0F3H
             SETB  EA //开总中断
             RET
主程序
START:       LCALL   CLEARMEMIO 
;
MAIN:        LCALL   KEYWORK 
             LJMP    MAIN 
             NOP 
             NOP
             NOP 
             LJMP    START 
;                  T1中断服务程序
INTT1:       CPL     P3.5 
             RET1
KEYWORK:     MOV     KEYY,#0FFH 
             CLR     KEYX0 
             CLR     KEYX1
             CLR     KEYX2
             CLR     KEYX3
             MOV     A,KEYY
             MOV     B,A
             CLNE    A,#0FFH,KKEYHIT  
KEYOUT:      RET
;
KEYHIT:      LCALL    DL10MS  
             MOV      A,KEYY 
             CJNE     A,B,KEYOUT
             SETB     KEYX1 
             SETB     KEYX2
             SETB     KEYX3
             MOV      A,KEYY
             CJNE     A,#0FFH,KEYVAL0 
             SETB     KEYX0 
             CLR      KEYX1
             MOV      A,KEYY
             CJNE     A,#0FFH,KEYVAL1
             SETB     KEYX1
             CLR      KEYX2
             MOV      A,KEYY
             CJNE     A,#0FFH,KEYVAL2
             SETB     KEYX2
             CLR      KEYX3
             MOV      A,KEYY
             CJNE     A,#0FFH,KEYVAL3
             LJMP     KEYOUT
;
KEYVAL0:     MOV      R2,#00H
             LJMP     KEYVAL4
;
KEYVAL1:     MOV      R2,#08H
             LJMP     KEYVAL4
;
KEYVAL2:     MOV      R2,#10H
             LJMP     KEYVAL4
;
KEYVAL3:     MOV      R2,#18H
             LJMP     KEYVAL4
;
KEYVAL4:     MOV      DPTR,#KEYVALTAB
             MOV      B,A
             CLR      A
             MOV      R0,A
KEYVAL5:     MOV      A,R0
             SUBB     A,#08H
             JNC      KEYOUT
             MOV      A,R0
             MOVC     A,@A+DPTR
             INC      R0
             CJNE     A,B,KEYVAL5
             DEC      R0
             MOV      A,R0
             ADD      A,R2
             MOV      B,A
             RL       A
             ADD      A,B
             MOV      DPTR,#KEYFUNTAB
             JMP      @A+DPTR
KEYFUNTAB:   LJMP     KEYFUN00
             LJMP     KEYFUN01
             LJMP     KEYFUN02
             LJMP     KEYFUN03
             LJMP     KEYFUN04
             LJMP     KEYFUN05
             LJMP     KEYFUN06
             LJMP     KEYFUN07
KEYVALTAB    DB      0FEH,0FDH,0FBH,0F7H,0EFH,ODFH,0BFH,7FH;
             RET
;
KEYFUN00:    MOV      A,#02H
             LJMP     REMOTE
             RET
;
KEYFUN01:    MOV      A,#03H
             LJMP     REMOTE
             RET
;
KEYFUN02:    MOV      A,#04H
             LJMP     REMOTE
             RET
;
KEYFUN03:    MOV      A,#05H
             LJMP     REMOTE
             RET
;
KEYFUN04:    MOV      A,#06H
             LJMP     REMOTE
             RET
;
KEYFUN05:    MOV      A,#07H
             LJMP     REMOTE
             RET
;
KEYFUN06:    MOV      A,#08H
             LJMP     REMOTE
             RET
;
KEYFUN07:    MOV      A,#09H
             LJMP     REMOTE
             RET
;
    编码发射程序
REMOTE:      MOV      R1,A
             LJMP     OUT3
OUT:         MOV      R0,#55H
OUT1:        SETB     ET1//开定时器中断
             SETB      TR1//启动定时器
             NOP
             NOP
             NOP
             NOP
             NOP
             DJNZ      R0,OUT1
             MOV       R0,#32H
OUT2:        CLR       TR1
             CLR       ET1
             CLR       P3.5
             NOP
             NOP
             NOP
             NOP
             NOP
             DJNZ       R0,OUT2
             DJNZ       R1,OUT
             LCALL      DL500MS
             RET
OUT3:        MOV        R0,#0FFH
             LJMP       OUT1
    延时513μS
DELAY:       MOV        R2,#0FFH
DELAY1:      DJNZ       R2,DELAY1
             RET
    10ms延时程序
DL10MS:      MOV        R3,#14H
DL10MS1:     LCALL      DELAY
             DJNZ       R3,DL10MS1
             RET
;
             END
   

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝