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

📄 int1.asm

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

include "m8c.inc"
include "memory.inc"
;include "int1.inc"

;-----------------------------------------------
;  Global Symbols
;-----------------------------------------------
export  _INT1_MS
;-----------------------------------------------
;@@variable
;-----------------------------------------------

AREA InterruptRAM (RAM,REL,CON)

;@PSoC_UserCode_INIT@ (Do not change this line.)
;---------------------------------------------------
; Insert your custom declarations below this banner
;---------------------------------------------------
EXPORT INT1_NEW
 INT1_NEW:	                    BLK   1    ;Receive temp when using INT1
EXPORT INT1_TEMP
 INT1_TEMP:                     BLK   1    ;Receive temp when using INT1
EXPORT INT1_BITCOUNT
 INT1_BITCOUNT:                 BLK   1    ;Receive bit counter when using INT1
EXPORT INT1_BYTECOUNT
 INT1_BYTECOUNT:                BLK   1    ;Receive byte counter when using INT1 
EXPORT INT1_DATA
 INT1_DATA:      		        BLK   1    ;Receive byte counter when using INT1 
EXPORT INT1_BYTE0
 INT1_BYTE0:	                    BLK   1    ;Receive data0 when using INT1  
EXPORT INT1_BYTE1
 INT1_BYTE1:	                    BLK   1    ;Receive data1 when using INT1
EXPORT INT1_BYTE2
 INT1_BYTE2:	                    BLK   1    ;Receive data2 when using INT1
EXPORT INT1_BYTE3
 INT1_BYTE3:	                    BLK   1    ;Receive data3 when using INT1
EXPORT INT1_BYTE4
 INT1_BYTE4:	                    BLK   1    ;Receive data4 counter when using INT1
EXPORT INT1_BYTE5
 INT1_BYTE5:	                    BLK   1    ;Receive data5 counter when using INT1
EXPORT INT1_BYTE6
 INT1_BYTE6:	                    BLK   1    ;Receive data6 counter when using INT1
EXPORT INT1_BYTE7
 INT1_BYTE7:	                    BLK   1    ;Receive data7 counter when using INT1
  
;------------------------
; 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: _INT1_KB
;
;  DESCRIPTION: Unless modified, this implements only a null handler stub.
;
;-----------------------------------------------------------------------------
_INT1_MS:

   ;@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		[INT1_BITCOUNT]	
	INC		[INT1_NEW]
    MOV		A, REG[P0DATA]			; got the data
    MOV		[INT1_TEMP],A
    AND		[INT1_TEMP],02h			; only the P0.1 is reserved 				
	
	CMP		[INT1_BITCOUNT],02h
	JZ		RC_MS_BIT0
	CMP		[INT1_BITCOUNT],03h
	JZ		RC_MS_BIT1			 
	CMP		[INT1_BITCOUNT],04h
	JZ		RC_MS_BIT2			 
	CMP		[INT1_BITCOUNT],05h
	JZ		RC_MS_BIT3			 
	CMP		[INT1_BITCOUNT],06h
	JZ		RC_MS_BIT4			 
	CMP		[INT1_BITCOUNT],07h
	JZ		RC_MS_BIT5			 
	CMP		[INT1_BITCOUNT],08h
	JZ		RC_MS_BIT6			 
	CMP		[INT1_BITCOUNT],09h
	JZ		RC_MS_BIT7
	CMP		[INT1_BITCOUNT],0Bh
	JZ		RC_MS_BYTE			 
    JMP		END_RECEIVE
    
RC_MS_BIT0:
	MOV		A,[INT1_TEMP]
	ASR		A	
	OR		[INT1_DATA],A
	JMP		END_RECEIVE
RC_MS_BIT1:
	MOV		A,[INT1_TEMP]
	OR		[INT1_DATA],A
	JMP		END_RECEIVE
RC_MS_BIT2:
	MOV		A,[INT1_TEMP]
	ASL		A
	OR		[INT1_DATA],A
	JMP		END_RECEIVE
RC_MS_BIT3:
	MOV		A,[INT1_TEMP]
	ASL		A
	ASL		A
	OR		[INT1_DATA],A
	JMP		END_RECEIVE		
RC_MS_BIT4:
	MOV		A,[INT1_TEMP]
	ASL		A
	ASL		A
	ASL		A
	OR		[INT1_DATA],A
	JMP		END_RECEIVE	
RC_MS_BIT5:
	MOV		A,[INT1_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	OR		[INT1_DATA],A
	JMP		END_RECEIVE			
RC_MS_BIT6:
	MOV		A,[INT1_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	OR		[INT1_DATA],A
	JMP		END_RECEIVE	
RC_MS_BIT7:
	MOV		A,[INT1_TEMP]
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	ASL		A
	OR		[INT1_DATA],A
	JMP		END_RECEIVE	
RC_MS_BYTE:
	INC		[INT1_BYTECOUNT]
	MOV		[INT1_BITCOUNT],00h
	CMP		[INT1_BYTECOUNT],01h
	JZ		RC_MS_BYTE0
	CMP		[INT1_BYTECOUNT],02h
	JZ		RC_MS_BYTE1
	CMP		[INT1_BYTECOUNT],03h
	JZ		RC_MS_BYTE2
	CMP		[INT1_BYTECOUNT],04h
	JZ		RC_MS_BYTE3
	CMP		[INT1_BYTECOUNT],05h
	JZ		RC_MS_BYTE4
	CMP		[INT1_BYTECOUNT],06h
	JZ		RC_MS_BYTE5
	CMP		[INT1_BYTECOUNT],07h
	JZ		RC_MS_BYTE6
	CMP		[INT1_BYTECOUNT],08h
	JZ		RC_MS_BYTE7
	JMP		END_RECEIVE	
RC_MS_BYTE0:
	MOV		[INT1_BYTE0],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE1:
	MOV		[INT1_BYTE1],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE2:
	MOV		[INT1_BYTE2],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE3:
	MOV		[INT1_BYTE3],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE4:
	MOV		[INT1_BYTE4],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE5:
	MOV		[INT1_BYTE5],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE6:
	MOV		[INT1_BYTE6],[INT1_DATA]
	JMP		END_RECEIVE
RC_MS_BYTE7:
	MOV		[INT1_BYTE7],[INT1_DATA]
	MOV		[INT1_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 INT1.asm

⌨️ 快捷键说明

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