VCP201_CODE is a FPGA source code.

源代码在线查看: decode.asm

软件大小: 586 K
上传用户: apsdn
关键词: source CODE FPGA code
下载地址: 免注册下载 普通下载 VIP

相关代码

				;****************************************************************************
				;FUNCTION: THIS ROUTINE IS TO DECODE EACH STEP DATA INTO BUTTON PATTERN.
				;          THE INPUT IS A POINTER POINTS AT THE CURRENT STEP DATA.  THE FIRST
				;          BYTE IS RETRIEVED AND TESTED TO CONFIRM THE STEP LENGTH.  DECODED
				;          PATTERN IS STORED TO THE DECODED BUFFERS (2 BYTES) AND THE LENGTH
				;          OF THE STEP TO W REGISTER.  THE INPUT POINTER IS MODIFIED TO
				;          POINT AT THE NEXT STEP ON EXIT.  REPEAT FUNCTION WILL BE DECODED
				;          TO NUMBER OF TIME OF REPETITION TO SET STEP TIMER TO 1, 2, 4 AND
				;          8 AS REQUIRED.  THE DECODED PATTERN WILL BE THE LAST VALID FIRE
				;          STEP PATTERN.
				;FILENAME: C:\PROJECTS\SV363\DECODE.ASM
				;ROUTINE NAME: DECODE
				;INPUT: PTR_NXT WHICH POINTS AT THE CURRENT STEP LOCATION
				;OUTPUT: W REGISTER = CURRENT STEP SIZE
				;        DCODE_PB0, DCODE_PB1 = DECODED BIT PATTERN
				;        PTR_NXT = NEXT STEP POINTER
				;        LAST_PB0, LAST_PB1 = DECODED BIT PATTERN
				;        dur_step = STEP DURATION
				;RAM AFFECTED: 65H,64H,63H,5EH,5DH,61H,60H
				;SUBROUTINE CALL: 
				;****************************************************************************
				;
				#define         step_buf0       pgm_buf0        ;RAM LOCATION 65H
				#define         step_buf1       pgm_buf1        ;RAM LOCATION 64H
				#define         step_buf2       pgm_buf2        ;RAM LOCATION 63H
				#define         dcode_pb0       ee_buf0         ;RAM LOCATION 5EH
				#define         dcode_pb1       ee_buf1         ;RAM LOCATION 5DH
				#define         last_pb0        mem_free        ;RAM LOCATION 6BH
				#define         last_pb1        data_length     ;RAM LOCATION 66H
				;
				decode:
					movfw   ptr_nxt         ;USE INDIRECT TO ACCESS STEP INFORMATION
					movw    FSR             ;AND STORE TO STEP BUFFERS
					movfw   INDF
					movw    step_buf0
					incf    FSR,F
					movfw   INDF
					movw    step_buf1
					incf    FSR,F
					movfw   INDF
					movw    step_buf2
				;
					movlw   0xff            ;INITIALIZE DCODE_PB'S TO FF
					movw    dcode_pb0
					movw    dcode_pb1
				;
					movlw   0xff            ;SEE IF 1ST BYTE = FF -> MULTI BUTTON STEP
					subwf   step_buf0,W
					skpz
					goto    three_pb        ;GOTO CHECK IF THREE BUTTON CODE
				multipb:
					movfw   step_buf1       ;BUFFER ALREADY CONTAINS BIT PATTERN
					movw    dcode_pb1       ;SO CAN DIRECTLY STORE TO DECODED BUFFER
					movw    last_pb1        ;STORE ALSO TO LAST_PB BUFFER FOR REPEAT STEP
					movfw   step_buf2
					movw    dcode_pb0
					movw    last_pb0
					movlw   STEP_TMR_1      ;SET STEP TIMER TO DEFAULT 1
					movw    dur_step
					movlw   STEP_SIZE_3     ;UPDATE NEXT STEP POINTER AND W = STEP SIZE
					addwf   ptr_nxt,F
					return
				;
				three_pb:
					movlw   0x0f            ;MASK THE LOWER DIGIT TO TEST FOR 3 BUTTON
					iorwf   step_buf0,W     ;STEP IF RESULT IS FF
					clrc
					addlw   0x1             ;INCREMENT TO SEE IF CARRY SET
					skpc                    ;IF CARRY SET -> THREE BUTTON STEP
					goto    one_pb0
					movlw   0x0f            ;MASK THE UPPER DIGIT TO LOCATE BIT ASSERTED
					andwf   step_buf0,W     ;RETRIEVE THE BIT INFORMATION TO W REGISTER
					call    clr_pb_bit
					movlw   0x0f            ;MASK THE NEXT BYTE AGAIN TO RETRIEVE THE
					andwf   step_buf1,W     ;SECOND BIT ASSERTED DATA
					call    clr_pb_bit
					swapf   step_buf1,F     ;TRANSFER THE UPPER DIGIT TO LOWER DIGIT
					movlw   0x0f            ;TO RETRIEVE THE THIRD BIT ASSERTED DATA
					andwf   step_buf1,W     ;MASK TO GIVE THE ASSERTED BIT #
					call    clr_pb_bit
					movfw   dcode_pb1       ;STORE THE DECODED PB'S TO LAST PB'S
					movw    last_pb1        
					movfw   dcode_pb0
					movw    last_pb0
					movlw   STEP_TMR_1      ;SET STEP TIMER TO DEFAULT 1
					movw    dur_step
					movlw   STEP_SIZE_2     ;UPDATE NEXT STEP POINTER AND W = STEP SIZE
					addwf   ptr_nxt,F
					return
				;
				one_pb0:
					movfw   step_buf0       ;SEE IF UPPER DIGIT = LOWER DIGIT
					swapf   step_buf0,F     ;IF EQUAL -> ONE BUTTON STEP
					subwf   step_buf0,W
					swapf   step_buf0,F     ;SWAP BACK THE HIGH & LOW DIGIT 
					skpz
					goto    two_pb0
					movlw   0x0f            ;SET UP W TO MASK UPPER DIGIT
					andwf   step_buf0,F     ;STEP_BUF0 NOW = BIT # ASSERTED
					movfw   step_buf0
					sublw   0x0e            ;SEE IF IDLE PERIOD
					skpnz
					goto    idle_pb
				;        
					movfw   step_buf0
					call    clr_pb_bit      ;CLEAR THE CORRESPONDING BIT IN DECODE BUFFER
					movfw   dcode_pb1       ;STORE THE DECODED PB'S TO LAST PB'S
					movw    last_pb1        
					movfw   dcode_pb0
					movw    last_pb0
					movlw   STEP_TMR_1      ;SET STEP TIMER TO DEFAULT 1
					movw    dur_step
					movlw   STEP_SIZE_1     ;UPDATE NEXT STEP POINTER AND W = STEP SIZE
					addwf   ptr_nxt,F
					return
				;
				two_pb0:
					movlw   0x0f            ;MASK THE LOWER DIGIT TO RETRIVE THE
					iorwf   step_buf0,W     ;HIGHER DIGIT TO SEE IF 'E'
					sublw   0xef
					skpnz
					goto    sp_func
				;
					movlw   0x0f            ;MASK THE UPPE DIGIT TO RETRIEVE THE
					andwf   step_buf0,W     ;FIRST BIT ASSERTED DATA
					call    clr_pb_bit
					swapf   step_buf0,F     ;TRANSFER THE UPPER DIGIT TO LOWER DIGIT
					movlw   0x0f            ;TO RETRIEVE THE SECOND BIT ASSERTED DATA
					andwf   step_buf0,W     ;MASK TO GIVE THE ASSERTED BIT #
					call    clr_pb_bit
					movfw   dcode_pb1       ;STORE THE DECODED PB'S TO LAST PB'S
					movw    last_pb1        
					movfw   dcode_pb0
					movw    last_pb0
					movlw   STEP_TMR_1      ;SET STEP TIMER TO DEFAULT 1
					movw    dur_step
					movlw   STEP_SIZE_1     ;UPDATE NEXT STEP POINTER AND W = STEP SIZE
					addwf   ptr_nxt,F
					return
				;
				sp_func:                        ;SEE IF SPECIAL FUNCTION BUTTON
					movlw   0x0f            ;SET TO MASK UPPER DIGIT
					andwf   step_buf0,W     ;RETRIEVE THE LOWER DIGIT
					movw    step_buf1       ;USE THE STEP_BUF1 AS TEMPORARY STORAGE BYTE
					sublw   0x3             ;SEE IF LOWER DIGIT < 4
					skpc                    ;IF LOWER DIGIT > 3, CODE IS AN IDLE PERIOD
					goto    idle_pb         ;TREAT IF AS IDLE PERIOD IN > 3
					bz      repeat_8        ;IF W=3 -> REPEAT STEP 8 TIMES
					movfw   step_buf1       ;RETRIEVE THE LOWER DIGIT
					sublw   0x2             ;SEE IF LOWER DIGIT = 2
					bz      repeat_4        ;IF LOWER DIGIT =2 -> REPEAT 4 TIMES
					movfw   step_buf1       ;RETRIEVE THE LOWER DIGIT
					sublw   0x1             ;SEE IF LOWER DIGIT = 2
					bz      repeat_2        ;IF LOWER DIGIT =2 -> REPEAT 2 TIMES
					goto    repeat_1        ;OTHERWISE LOWER DIGIT -> REPEAT 1 TIMER
				repeat_8:
					movlw   STEP_TMR_8      ;SET STEP TIMER TO 8
					movw    dur_step
					goto    repeat_end
				repeat_4:
					movlw   STEP_TMR_4      ;SET STEP TIMER TO 4
					movw    dur_step
					goto    repeat_end
				repeat_2:
					movlw   STEP_TMR_2      ;SET STEP TIMER TO 2
					movw    dur_step
					goto    repeat_end
				repeat_1:
					movlw   STEP_TMR_1      ;SET STEP TIMER TO 1
					movw    dur_step
				repeat_end:
					movfw   last_pb0        ;USE THE LAST BIT PATTERN
					movw    dcode_pb0
					movfw   last_pb1
					movw    dcode_pb1
					movlw   STEP_SIZE_1     ;SET STEP SIZE TO W
					addwf   ptr_nxt,F       ;UPDATE NEXT STEP POINTER
					return
				;
				idle_pb:
					movfw   dcode_pb1       ;STORE THE DECODED PB'S TO LAST PB'S
					movw    last_pb1        
					movfw   dcode_pb0
					movw    last_pb0
					movlw   STEP_TMR_1      ;SET STEP DURATION TIMER
					movw    dur_step
					movlw   STEP_SIZE_1     ;SET STEP SIZE TO 1
					addwf   ptr_nxt,F       ;UPDATA NEXT STEP POINTER
					return
				;
				;
				;****************************************************************************
				;FUNCTION: THIS ROUTINE IS TO CLEAR THE ASSERTED BIT IN THE DECODE BUFFER TO
				;          TO THE BUTTON PATTERN.  INPUT IS LOCATION WHERE THE BIT IS TO BE
				;          CLEAR.  ON EXIT, THE CORRESPONDING DECODE BUFFER BIT WILL BE CLEAR
				;FILENAME: C:\PROJECTS\SV363\DECODE.ASM
				;ROUTINE NAME: CLEAR_PB_BIT
				;INPUT: W = LOCATION OF BIT TO BE CLEAR
				;OUTPUT: IF W < 8, CORRESPONDING BIT LOCATION IN DCODE_PB0 WILL BE 0
				;        IF 7 < W, W = W - 8 AND CORRESPONDING BIT LOCATION IN DECODE_PB1
				;        WILL BE CLEAR.
				;RAM AFFECTED: IN_BIT_LOC
				;SUBROUTINE CALL: NIL
				;****************************************************************************
				;
				;#define in_bit_loc      temp_buf3       ;RAM LOCATION 5FH
				;
				clr_pb_bit:
					movw    in_bit_loc      ;STORE TO INPUT BIT LOCATION TO BUFFER
					skpz
					goto    clr_1
					bcf     dcode_pb0,0
					return
				clr_1:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 1
					goto    clr_2
					bcf     dcode_pb0,1
					return
				clr_2:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 2
					goto    clr_3
					bcf     dcode_pb0,2
					return
				clr_3:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 3
					goto    clr_4
					bcf     dcode_pb0,3
					return
				clr_4:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 4
					goto    clr_5
					bcf     dcode_pb0,4
					return
				clr_5:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 5
					goto    clr_6
					bcf     dcode_pb0,5
					return
				clr_6:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 6
					goto    clr_7
					bcf     dcode_pb0,6
					return
				clr_7:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 7
					goto    clr_8
					bcf     dcode_pb0,7
					return
				clr_8:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 8
					goto    clr_9
					bcf     dcode_pb1,0
					return
				clr_9:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 9
					goto    clr_10
					bcf     dcode_pb1,1
					return
				clr_10:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 10
					goto    clr_11
					bcf     dcode_pb1,2
					return
				clr_11:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 11
					goto    clr_12
					bcf     dcode_pb1,3
					return
				clr_12:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 12
					goto    clr_13
					bcf     dcode_pb1,4
					return
				clr_13:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 13
					goto    clr_14
					bcf     dcode_pb1,5
					return
				clr_14:
					decfsz  in_bit_loc,F    ;=0 -> clear bit 14
					goto    clr_15
					bcf     dcode_pb1,6
					return
				clr_15:
					bcf     dcode_pb1,7
					return
				
				
							

相关资源