1、 上电初始化(RAM14=FFH,Flag=0000 0001B,0000 0010B, 0000 0100B,0000 1000, 0001 0000B)主程序扫描 COM1(第一行)是否有键值 yes 装载缓冲区( RAM14)NO RAM1 LED 送显示延时 2ms扫描 COM2 (第二行).扫描 COM4 (第四行)主程序装载缓冲区:BTFSC Flag.0GOTO Load RAM2键值 RAM1GOTO Load RAM1Load RAM2:BTFSC Flag.1GOTO Load RAM3键值 RAM2GOTO Load RAM1Load RAM3: BTFSC Flag.2
2、GOTO Load RAM4键值 RAM3GOTO Load RAM1Load RAM4: 键值 RAM4Load RAM1:清除进位,借位标志位 CFlag 左移一位BTFSS Flag.4GOTO Load ENDFlag = 0000 0001BLoad END:RETURN实例:Buffer: LoadRAM1:btfss Flag,0goto LoadRAM2movwf RAM1goto Load1LoadRAM2:btfss Flag,1goto LoadRAM3movwf RAM2goto Load1LoadRAM3: btfss Flag,2goto LoadRAM4movwf RAM3goto Load1 LoadRAM4:btfss Flag,3goto LoadRAM1movwf RAM4goto Load1Load1: bcf status,Crlf Flag,1btfss Flag,4goto Loadendmovlw 00000001Bmovwf Flag Loadend: return