⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 int0.asm

📁 实现2个ps/2接口转到1个USB接口功能
💻 ASM
字号:
;;*****************************************************************************
;;*****************************************************************************
;;  FILENAME: INT0.asm
;;  DESCRIPTION:
;;    Interrupt handler routine for INT0.INT0 is associated with P0.2 which is the signal of keyboard clock.
;;-----------------------------------------------------------------------------
;;*****************************************************************************
;;*****************************************************************************

include "m8c.inc"
include "memory.inc"
;include "int0.inc"

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
export  _INT0_KB
;-----------------------------------------------
;@@variable
;-----------------------------------------------

AREA InterruptRAM (RAM,REL,CON)

;@PSoC_UserCode_INIT@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom declarations below this banner
;---------------------------------------------------
EXPORT INT0_NEW
 INT0_NEW:	                    BLK   1    ;Receive temp when using INT0
EXPORT INT0_TEMP
 INT0_TEMP:                     BLK   1    ;Receive temp when using INT0
EXPORT INT0_BITCOUNT
 INT0_BITCOUNT:                 BLK   1    ;Receive bit counter when using INT0
EXPORT INT0_BYTECOUNT
 INT0_BYTECOUNT:                BLK   1    ;Receive byte counter when using INT0 
EXPORT INT0_DATA
 INT0_DATA:      		        BLK   1    ;Receive byte counter when using INT0 
EXPORT INT0_BYTE0
 INT0_BYTE0:	                    BLK   1    ;Receive data0 when using INT0  
EXPORT INT0_BYTE1
 INT0_BYTE1:	                    BLK   1    ;Receive data1 when using INT0
EXPORT INT0_BYTE2
 INT0_BYTE2:	                    BLK   1    ;Receive data2 when using INT0
EXPORT INT0_BYTE3
 INT0_BYTE3:	                    BLK   1    ;Receive data3 when using INT0
EXPORT INT0_BYTE4
 INT0_BYTE4:	                    BLK   1    ;Receive data4 counter when using INT0
EXPORT INT0_BYTE5
 INT0_BYTE5:	                    BLK   1    ;Receive data5 counter when using INT0
EXPORT INT0_BYTE6
 INT0_BYTE6:	                    BLK   1    ;Receive data6 counter when using INT0
EXPORT INT0_BYTE7
 INT0_BYTE7:	                    BLK   1    ;Receive data7 counter when using INT0
  
;------------------------
; Includes
;------------------------

	
;------------------------
;  Constant Definitions
;------------------------


;------------------------
; Variable Allocation
;------------------------


;---------------------------------------------------
; Insert your custom declarations above this banner
;---------------------------------------------------
;@PSoC_UserCode_END@ (Do not change this line.)


AREA text (ROM, REL)

;-----------------------------------------------------------------------------
;  FUNCTION NAME: _INT0_KB
;
;  DESCRIPTION: Unless modified, this implements only a null handler stub.
;
;-----------------------------------------------------------------------------
_INT0_KB:

   ;@PSoC_UserCode_RX@ (Do not change this line.)
   ;---------------------------------------------------
   ; Insert your custom code below this banner
   ;---------------------------------------------------
   ;   NOTE: interrupt service routines must preserve
   ;   the values of the A and X CPU registers.
	M8C_DisableGInt
	INC		[INT0_BITCOUNT]	
	INC		[INT0_NEW]
    MOV		A, REG[P0DATA]			; got the data
    MOV		[INT0_TEMP],A
    AND		[INT0_TEMP],01h			; only the P0.0 is reserved 				
	
	CMP		[INT0_BITCOUNT],02h
	JZ		RC_KB_BIT0
	CMP		[INT0_BITCOUNT],03h
	JZ		RC_KB_BIT1			 
	CMP		[INT0_BITCOUNT],04h
	JZ		RC_KB_BIT2			 
	CMP		[INT0_BITCOUNT],05h
	JZ		RC_KB_BIT3			 
	CMP		[INT0_BITCOUNT],06h
	JZ		RC_KB_BIT4			 
	CMP		[INT0_BITCOUNT],07h
	JZ		RC_KB_BIT5			 
	CMP		[INT0_BITCOUNT],08h
	JZ		RC_KB_BIT6			 
	CMP		[INT0_BITCOUNT],09h
	JZ		RC_KB_BIT7
	CMP		[INT0_BITCOUNT],0Bh
	JZ		RC_KB_BYTE			 
    JMP		END_RECEIVE
    
RC_KB_BIT0:
	MOV		A,[INT0_TEMP]
	OR		[INT0_DATA],A
	JMP		END_RECEIVE
RC_KB_BIT1:
	MOV		A,[INT0_TEMP]
	ASL		A
	OR		[INT0_DATA],A
	JMP		END_RECEIVE
RC_KB_BIT2:
	MOV		A,[INT0_TEMP]
	ASL		A
	ASL		A
 	OR		[INT0_DATA],A
	JMP		END_RECEIVE
RC_KB_BIT3:
	MOV		A,[INT0_TEMP]
	ASL		A
	ASL		A
	ASL		A
	OR		[INT0_DATA],A
	JMP		END_RECEIVE		
RC_KB_BIT4:
	MOV		A,[INT0_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	OR		[INT0_DATA],A
	JMP		END_RECEIVE	
RC_KB_BIT5:
	MOV		A,[INT0_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	OR		[INT0_DATA],A
	JMP		END_RECEIVE	
RC_KB_BIT6:
	MOV		A,[INT0_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A	
	ASL		A
	OR		[INT0_DATA],A
	JMP		END_RECEIVE	
RC_KB_BIT7:
	MOV		A,[INT0_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A	
	ASL		A
	OR		[INT0_DATA],A
	JMP		END_RECEIVE	
RC_KB_BYTE:
	INC		[INT0_BYTECOUNT]
	MOV		[INT0_BITCOUNT],00h
	CMP		[INT0_BYTECOUNT],01h
	JZ		RC_KB_BYTE0
	CMP		[INT0_BYTECOUNT],02h
	JZ		RC_KB_BYTE1
	CMP		[INT0_BYTECOUNT],03h
	JZ		RC_KB_BYTE2
	CMP		[INT0_BYTECOUNT],04h
	JZ		RC_KB_BYTE3
	CMP		[INT0_BYTECOUNT],05h
	JZ		RC_KB_BYTE4
	CMP		[INT0_BYTECOUNT],06h
	JZ		RC_KB_BYTE5
	CMP		[INT0_BYTECOUNT],07h
	JZ		RC_KB_BYTE6
	CMP		[INT0_BYTECOUNT],08h
	JZ		RC_KB_BYTE7
	JMP		END_RECEIVE	
RC_KB_BYTE0:
	MOV		[INT0_BYTE0],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE1:
	MOV		[INT0_BYTE1],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE2:
	MOV		[INT0_BYTE2],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE3:
	MOV		[INT0_BYTE3],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE4:
	MOV		[INT0_BYTE4],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE5:
	MOV		[INT0_BYTE5],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE6:
	MOV		[INT0_BYTE6],[INT0_DATA]
	JMP		END_RECEIVE
RC_KB_BYTE7:
	MOV		[INT0_BYTE7],[INT0_DATA]
	MOV		[INT0_BYTECOUNT],00h	
	JMP		END_RECEIVE	
	
END_RECEIVE:
   M8C_EnableGInt
   reti
   ;---------------------------------------------------
   ; Insert your custom code above this banner
   ;---------------------------------------------------
   ;@PSoC_UserCode_END@ (Do not change this line.)

; end of file INT0.asm

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -