汇编之间断申请(例子)

汇编之中断申请(例子)
;*****************************************************************************
;  This file is a base code template for assembley code generation on the 8PE53.
;*****************************************************************************
;* TITLE        :
;* REVISION     :
;* AUTHOR       :
;* COMPANY      :
;* DATE         :
;* CHIP         :8PE53
;* CONFIG       :
;*****************************************************************************


;---------------Include files Segment-----------------------------------------
#include        <8PE53.ASH>
;---------------Custom define segment-----------------------------------------
RG_INT_ACCTMP   REG     0x10                    ;example register definition
RG_INT_STATMP   REG     0x11                    ;example register definition
RG_INT_PCHTMP   REG     0x12                    ;example register definition
;---
RG_TEMP         REG     0x13                    ;example register definition


RG_COUNT0 REG  0x15
RG_COUNT1 REG  0x16
RG_COUNT2 REG  0x17
RG_COUNT3 REG  0x18


;---------------vaule segment-------------------------------------------------
EQ_AAA          EQU     0x55                    ;example value definition






;---------------Program segment-----------------------------------------------
                ORG     0x000


;---------------Software Interrupt Vector segment-----------------------------
                ORG     0x002                   ;Software INT vector
                                                ;Software interrupt program is written here.


;---------------Hardware Interrupt Vector segment-----------------------------
                ORG     0x008                   ;Hardware INT vector
                MOVAR   RG_INT_ACCTMP
                SWAPR   STATUS,A
                MOVAR   RG_INT_STATMP
                SWAPR   PCHBUF,A
                MOVAR   RG_INT_PCHTMP           ;Save ACC STATUS PCHBUF template code
                ;---


INCR RG_COUNT0, 1;Increament RGCOUNT0
BTRSC STATUS, 2;Test STATUS Z bit
INCR RG_COUNT1, 1;If RG_COUNT0 is verflow, increse RG_COUNT1
ANDIA 0X04

;---
            MOVIA 0X00                    ;Hardware interrupt program is written here.
MOVAR INTFLAG;Clear interrupt FLA FLAG                ;---
INT_EXIT:
                SWAPR   RG_INT_PCHTMP,A
                MOVAR   PCHBUF
                SWAPR   RG_INT_STATMP,A
                MOVAR   STATUS
                SWAPR   RG_INT_ACCTMP,R
                SWAPR   RG_INT_ACCTMP,A
                RETFIE                          ;Restore ACC STATUS PCHBUF template code


;--------------------init---------------------
INIT:             
CLRA
MOVAR   PORTB
MOVIA 0X00
IOST PORTB  ;Set PortB to output mode, IOB3 is input only


MOVIA 0X00
OPTION ;Use internel clock source


MOVIA 0X81
MOVAR INTEN;Enable time0 intr


CLRA
MOVAR RG_COUNT0;Init counter
MOVAR RG_COUNT1
MOVAR RG_COUNT2
MOVAR RG_COUNT3

GOTO    MAIN


;---------------------main--------------------
MAIN:
BTRSS RG_COUNT0,  0
GOTO    INIT
GOTO MAIN
;---------------MCU Boot/Reset Vector segment---------------------------------
                ORG     0x3FF                   ;MCU reset vector
                GOTO    INIT