2007年5月30日星期三

DEMO PROGRAM MDT10P63

; PROGRM NAME : AZ9730B Demo PROGRAM
;
; PROGRM NAME : DEMO_B.ASM
;
;CONSTANT
PORTA EQU 0FFH ;RA 8 BITS
PORTB EQU 0FFH ;RB 8 BITS
PORTC EQU 0FFH ;RC 8 BITS
PORTD EQU 0FFH ;RD 8 BITS
PORTE EQU 07H ;RE 3 BITS
RAMNO EQU 96 ;20H - FFH
TBLEND EQU 26H
;
; ***** REGISTER FILE ****
INDEX EQU 0
RTCC EQU 1
PC EQU 2
STUS EQU 3
FSR EQU 4
RA EQU 5 ;
RB EQU 6 ;
RC EQU 7 ;
RD EQU 8 ;
RE EQU 9 ;
RCH EQU 0AH ;PCH
IRQ EQU 0BH ;INTTERUPT
PIR1 EQU 0CH ;TIMER 1
PIR2 EQU 0DH ;PD INTTERUPT
T1L EQU 0EH ;TIMER 1 LOW BYTE
T1H EQU 0FH ;TIMER 1 HI BYTE
T1C EQU 10H ;TIMER CONTROL
TM1CR EQU 15H ;TIMER CONTROL
TM1CE EQU 17H ;TIMER CONTROL
TESTNO EQU 20H ;TEST NO
COUNT EQU 21H
ERROR EQU 22H
DLYCNT EQU 23H
DLYCT2 EQU 24H
TEMP EQU 25H
;********************
; STATUS FLAG
A EQU 0
CY EQU 0
DC EQU 1
ZF EQU 2
PD EQU 3
TO EQU 4
;********************

ORG 00H
LJUMP BEGIN

ORG 04H
BTSS 0BH,0
LCALL DELAY
BTSS 0DH,7
LCALL DELAY
BSR ERROR,0
BCR T1C,0
LDWI 00H
STWR IRQ
RTFI

ORG 030H
TNOISE
CLRWT
LDWI 08H
STWR COUNT
LDWI 7FH
STWR RA
STWR RB
STWR RC
STWR RD
STWR RE
BSR STUS,5 ; Set Page 1
CLRW
CPIO RA
CPIO RB
CPIO RC
STWR RD ; Set Port_D OUTPUT MODE
STWR RE ; Set Port_E OUTPUT MODE
BCR STUS,5

NTLOOP
LDWI 25H
STWR FSR

NORAM
CLRWT
LDR RA,A ;X->R(X) FOR X=20H - 7FH
STWR INDEX
INCR FSR
BTSS FSR,7
LJUMP NORAM
LDWI 0A0H
STWR FSR

NORAM1
CLRWT
LDR RB,A ;X->R(X) FOR X=A0H - FFH
STWR INDEX
INCRSZ FSR,1
LJUMP NORAM1
LDWI 25H
STWR FSR

NORAM2
CLRWT
LDR INDEX,A ;IF R(X)==RC FOR X=20H - 7FH OR NOT
XORWR RC,A
BTSS STUS,ZF
LJUMP POWER
INCR FSR
BTSS FSR,7
LJUMP NORAM2
LDWI 0A0H
STWR FSR

NORAM3
CLRWT
LDR INDEX,A ;IF R(X)==RD FOR X=A0H - FFH OR NOT
XORWR RD,A
BTSS STUS,ZF
LJUMP POWER
INCRSZ FSR,1
LJUMP NORAM3
NOP
LCALL DELAY
DECRSZ COUNT,1
LJUMP NORAM4
LDWI 08H
STWR COUNT
LDWI 7FH
STWR RA
STWR RB
STWR RC
STWR RD
STWR RE
LJUMP NTLOOP

NORAM4
BSR STUS,CY
RRR RA,1
RRR RB,1
RRR RC,1
RRR RD,1
INCR RE,1
LJUMP NTLOOP



ORG 01FFH
BEGIN
BTSS STUS,TO
LJUMP KEEP ;WDT WAKE-UP FROM TIME-OUT
BTSS STUS,PD
LJUMP MCLRSP ;/MCLR WAKE-UP FROM SLEEP

LDR RE,A
XORWI 01H
BTSS STUS,ZF
LJUMP TNOISE ;Test noise

POWER

BSR STUS,5 ; Set Page 1
LDWI 0FFH
CPIO RA
CPIO RB
CPIO RC
STWR RD ; Set Port_D OUTPUT MODE
STWR RE ; Set Port_E OUTPUT MODE
BCR STUS,5

POWERON
LDWI 7FH
STWR FSR
STWR RA
STWR RB
STWR RC
STWR RD
STWR RE
BSR STUS,5
LDWI 00H
STWR RE
BCR STUS,5
LDWI 0FEH ;RC=1110 , LF=1101 , XT=1100 , HF=1011
STWR RE
LCALL DELAY
BSR STUS,5
LDWI 0FFH
CPIO RB
STWR RE
BCR STUS,5
LJUMP PWRUP
;****************************************************************
;* POWER UP *
;* ERROR MESSAGE *
;* BIT 0,1 - STATUS INCORRECT *
;* BIT 2,3 - RB ERROR *
;****************************************************************

PWRUP CLRR ERROR ;CLEAR ERROR FLAG
CLRR TESTNO ;RESET TESTNO
LDWI 01DH ;IF STUS CORRECT OR NOT
STWR STUS
LDR STUS,A
ANDWI 0FDH
XORWI 01DH
BTSS STUS,ZF
BSR ERROR,0
LDWI 1AH
STWR STUS
LDR STUS,A
ANDWI 0EFH
XORWI 0AH
BTSS STUS,ZF
BSR ERROR,1

LDWI 10101010B
STWR RA
STWR RB
STWR RC
STWR RD
STWR RE
ANDWI PORTA
XORWR RA,A ;RA PULL-UP IN INPUT MODE
BTSC STUS,ZF ;IF RA INPUT DATA = OUTPUT DATA
BSR ERROR,2 ;THEN ERROR
LDWI 10101010B
ANDWI PORTB
XORWR RB,A ;RB PULL-UP IN INPUT MODE
BTSC STUS,ZF ;IF RB INPUT DATA = OUTPUT DATA
BSR ERROR,3 ;THEN ERROR
LDWI 10101010B
ANDWI PORTC
XORWR RC,A ;RC PULL-UP IN INPUT MODE
BTSC STUS,ZF ;IF RC INPUT DATA = OUTPUT DATA
BSR ERROR,4 ;THEN ERROR
LDWI 10101010B
ANDWI PORTD
XORWR RD,A ;RD IN INPUT MODE
BTSC STUS,ZF ;IF RD INPUT DATA = OUTPUT DATA
BSR ERROR,5 ;THEN ERROR
LDWI 10101010B
ANDWI PORTE
XORWR RE,A ;RE IN INPUT MODE
BTSC STUS,ZF ;IF RE INPUT DATA = OUTPUT DATA
BSR ERROR,6 ;THEN ERROR

BSR STUS,5
CLRW
CPIO RA
CPIO RB
CPIO RC
STWR RD ;RE OUTPUT MODE
STWR RE ;RE OUTPUT MODE
BCR STUS,5
LDWI 80H
STWR TEMP
P_LOOP
CLRWT
LDR TEMP,A
IORWR TEMP,A
STWR RA
STWR RB
STWR RC
STWR RD
STWR RE
XORWR TEMP,A
BTSS STUS,ZF ;IF NOT ZER0
BSR ERROR,7 ; THEN FAIL
LDR RB,A
ANDWI PORTB
XORWR RB,A
BTSS STUS,ZF
BSR ERROR,7
LCALL DELAY
BCR STUS,CY
RRR TEMP
BTSS STUS,CY
LJUMP P_LOOP ;RA,RB:10000000->01000000->00100000->00010000->
LDWI 1 ; 00001000->00000100->00000010->00000001
BCR STUS,CY
SUBWR TESTNO
INCR TESTNO
INCR TESTNO,A
STWR RE ;SHOW TEST NO.
LDR ERROR,0
STWR RA ;SHOW ERROR
STWR RB ;SHOW ERROR
STWR RC ;SHOW ERROR
STWR RD ;SHOW ERROR
SLEEP
LJUMP BEGIN


MCLRSP
LDWI 07FH ;RB AND RE OUTPUT
STWR FSR
CLRWT
LDWI 10001111B
TMODE
BSR STUS,5
CLRW
CPIO RB
STWR RE
BCR STUS,5
LDWI 0
XORWR TESTNO,A
BTSC STUS,ZF ;TESTNO = 00H TEST T_RAM
LJUMP T_RAM
LJUMP TAZ
TAZ
LDWI 02H
STWR RCH
LDWI 01H
SUBWR TESTNO,A
ADDWR PC
LJUMP T_PORT ;I/O PORT TEST & RAM DATA TEST
LJUMP T_RTCC ;RTCC TEST
LJUMP T_WDT ;WDT TEST
LJUMP INTTM0 ;PIN RESET TEST
LJUMP POWERON ;POWER ON
T_RAM
CLRWT
INCR TESTNO
INCR TESTNO,0
STWR RE
LCALL DELAY
CLRR ERROR
LDWI 26H ;STWRT RAMTEST AT 26H
STWR FSR
LCALL FTEST
LDR ERROR,0
STWR RB ;RB=00 IF SUCCESSFUL, RB=FFH FF ERROR
SLEEP
LJUMP BEGIN


FTEST
LDWI RAMNO ;RAMNO=96 BYTES TO TEST
STWR COUNT
LDWI 06H
SUBWR COUNT
FTEST1
CLRWT
LDR FSR,A ;X->R(X) FOR X=26H - 7FH
STWR INDEX
INCR FSR
DECRSZ COUNT
LJUMP FTEST1
LDWI 0A0H ;STWRT RAMTEST AT 26H
STWR FSR
LDWI RAMNO ;RAMNO=92 BYTES TO TEST
STWR COUNT
FTEST2
CLRWT
LDR FSR,A ;X->R(X) FOR X=26H - 7FH
STWR INDEX
INCR FSR
DECRSZ COUNT
LJUMP FTEST2
LDWI RAMNO
STWR COUNT
LDWI 0FFH
STWR FSR
FCHK1
CLRWT
LDR INDEX,A ;IF R(X)==X FOR X=1FH - 13H OR NOT
XORWR FSR,A
BTSS STUS,ZF
LJUMP FERR1
DECR FSR
DECRSZ COUNT
LJUMP FCHK1
LDWI RAMNO ;RAMNO=96 BYTES TO TEST
STWR COUNT
LDWI 06H
SUBWR COUNT ;RAMNO=90 BYTES TO TEST
LDWI 7FH
STWR FSR
FCHK2
CLRWT
LDR INDEX,A ;IF R(X)==X FOR X=1FH - 13H OR NOT
XORWR FSR,A
BTSS STUS,ZF
LJUMP FERR1
DECR FSR
DECRSZ COUNT
LJUMP FCHK2
RTIW 0
FERR1
LDR FSR,0
STWR ERROR ;TEST FAIL
RTIW 0

DELAY
LDWI 0FFH
STWR DLYCNT
LP1
LCALL DLY
DECRSZ DLYCNT
LJUMP LP1
RTIW 0
DLY
CLRR DLYCT2
DLY1
CLRWT
INCRSZ DLYCT2
LJUMP DLY1
RTIW 55H
T_PORT ;TEST PORT-B OUT 1. RB SHOW FSR
CLRWT
CLRR ERROR
INCR TESTNO
INCR TESTNO,0
STWR RE
LDR RE,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 03H
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,4 ; THEN FAIL
BSR STUS,5 ;
CLRW
CPIO RA
CPIO RC
STWR RD
BCR STUS,5 ; THEN FAIL
LDWI 55H
STWR RA
LDR RA,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 55H
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,0 ; THEN FAIL
LDWI 55H
STWR RB
LDR RB,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 55H
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,1 ; THEN FAIL
LDWI 55H
STWR RC
LDR RC,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 55H
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,2 ; THEN FAIL
LDWI 55H
STWR RD
LDR RD,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 55H
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,3 ; THEN FAIL
LDWI 0AAH
STWR RA
LDR RA,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 0AAH
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,0 ; THEN FAIL
LDWI 0AAH
STWR RB
LDR RB,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 0AAH
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,1 ; THEN FAIL
LDWI 0AAH
STWR RC
LDR RC,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 0AAH
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,2 ; THEN FAIL
LDWI 0AAH
STWR RD
LDR RD,0 ;15H ~ 1FH STWR 33H
STWR TEMP
LDWI 0AAH
XORWR TEMP,A
BTSS STUS,ZF ;IF INPUT DATA <> OUPUT DATA
BSR ERROR,3 ; THEN FAIL
BSR STUS,5
LDWI 0FFH
STWR RA
STWR RC
STWR RD
BCR STUS,5
LDR ERROR,0
STWR RB
SLEEP
LJUMP BEGIN


T_RTCC
CLRWT
LDWI 0
CPIO RB
INCR TESTNO
INCR TESTNO,0
STWR RE ;SHOW TEST NO.
CLRR RB
CLRR ERROR

LDWI 10101000B ;INC ON LOW TO HIGH EDGE
TMODE
CLRR RTCC
T_R4
CLRWT
LDR RTCC,A
STWR RB ;SHOW COUNT TO RB
LDWI 04H ;RTCC=0,1,2,3,4
STWR TEMP
RLR TEMP
RRR TEMP
LDR TEMP,A
BSR STUS,CY
SUBWR RB,A
BTSS STUS,ZF
LJUMP T_R4

LDWI 10111000B ;INC ON HIGH TO LOW EDGE
TMODE
T_R8
CLRWT
LDR RTCC,A
STWR RB ;RTCC=5,6,7,8
XORWI 08H
BTSS STUS,ZF
LJUMP T_R8

CLRR RB
T_R10
CLRWT
LCALL ONESEC
INCR RB
LDWI 10
XORWR RB,A
BTSS STUS,ZF ;IF COUNT 10 SEC, THEN STOP
LJUMP T_R10
CLRR RB
CLRR TEMP
T_R20
CLRWT
LDR TEMP,0
ANDWI 07H
LCALL ONESEC1
INCR TEMP
INCR RB
LDWI 10
XORWR RB,A
BTSS STUS,ZF ;IF COUNT 10 SEC, THEN STOP
LJUMP T_R20
CLRR TEMP
SLEEP
LJUMP BEGIN

ONESEC
LDWI 10000111B ;INTERNAL CLOCK, PSC=256
TMODE
LDWI 14 ;Freq = 4*256*(256-7)*14 = 3.57 MHz
STWR COUNT
O_S1
LDWI 7
STWR RTCC
O_S2
CLRWT
LDR RTCC,A
BTSS STUS,ZF
LJUMP O_S2
DECRSZ COUNT
LJUMP O_S1
RTIW 0
ONESEC1
LDWI 1000111B ;INTERNAL CLOCK, PSC=256
TMODE
LDWI 50 ;Freq = 4*256*(256-7)*14 = 3.57 MHz
STWR COUNT
O_S11
LDWI 7
STWR RTCC
O_S21
CLRWT
LDR RTCC,A
BTSS STUS,ZF
LJUMP O_S21
DECRSZ COUNT
LJUMP O_S11
RTIW 0
T_WDT
BSR STUS,5
CLRW
CPIO RB
STWR RE
BCR STUS,5
INCR TESTNO
INCR TESTNO,0
STWR RE
TWDT3
LDWI 08H
STWR COUNT
LDWI 80H
STWR ERROR
LDR ERROR,0
STWR RB
LDR COUNT,0
TMODE
SLEEP
LJUMP BEGIN

TWDT2
LDWI 01H
ADDWR COUNT
LJUMP WCOUNT

WCOUNT ;WDT 1 : 1 RB SHOW 80\H
CLRWT ;WDT 1 : 2 RB SHOW 40\H
BCR STUS,0 ;WDT 1 : 4 RB SHOW 20\H
RRR ERROR ;WDT 1 : 8 RB SHOW 10\H
LDR ERROR,0 ;WDT 1 : 16 RB SHOW 08\H
STWR RB ;WDT 1 : 32 RB SHOW 04\H
BTSC STUS,2 ;WDT 1 : 64 RB SHOW 02\H
LJUMP TWDT3 ;WDT 1 : 128 RB SHOW 01\H
LDR COUNT,0
TMODE
SLEEP
LJUMP BEGIN


KEEP
BSR STUS,5
CLRW
CPIO RB
STWR RE
BCR STUS,5
LDWI 04H
XORWR TESTNO,A
BTSC STUS,2
LJUMP TWDT2
CLRWT
SLEEP
LJUMP BEGIN

INTTM0
CLRWT
LDWI 0F0H
CPIO RA
LDWI 0FEH ;RA0~3 OUTPUT SHOW FEH
STWR RA
LDWI 0AFH
TMODE
INCR TESTNO
INCR TESTNO,0
STWR RE
CLRR ERROR
CLRR RTCC
LDWI 0F0H ;RTCC = F0H
STWR RTCC
LDWI 0A0H ;TEST INT TIMER0
STWR IRQ
TM0J
CLRWT
LDR RTCC,0
STWR RB
BTSS ERROR,0
LJUMP TM0J
INTRB0
LDWI 0FFH
CPIO RB
LDWI 0FDH ;RA0~3 OUTPUT SHOW FDH
STWR RA
LDWI 0DFH
TMODE
LDR RB,0 ;
LDWI 90H ;
STWR IRQ
CLRR ERROR
BB1
CLRWT
SLEEP
NOP
BTSS STUS,4
LJUMP BB1
INTRB01
LDWI 0FFH
CPIO RB
LDWI 0FCH ;RA0~3 OUTPUT SHOW FCH
STWR RA
LDWI 08FH
TMODE
LDR RB,0 ;
LDWI 90H ;
STWR IRQ
CLRR ERROR
BB2
CLRWT
SLEEP
NOP
BTSS STUS,4
LJUMP BB2
INTRB
CLRR TEMP
LDR TEMP,0
STWR RC
LDWI 00H
CPIO RC
LDWI 0FBH ;RA0~3 OUTPUT SHOW FBH
STWR RA
INTRB1
LDR TEMP,0
STWR RC
LDR RB,0 ;RC0~7 OUTPUT SHOW 00~07H
LDWI 88H
STWR IRQ
BB3
CLRWT
SLEEP
NOP
BTSS STUS,4
LJUMP BB3
INCR TEMP
BTSS TEMP,3
LJUMP INTRB1
INTRD
CLRR TEMP
LDR TEMP,0
STWR RC
LDWI 0FAH ;RA0~3 OUTPUT SHOW FAH
STWR RA
INTRD1
LDR TEMP,0
STWR RC ;RC0~7 OUTPUT SHOW 00~0FH
LDR RD,0
BCR PIR2,7
BSR STUS,5
BSR PIR2,7
BCR STUS,5
LDWI 0C0H
STWR IRQ
BB4
CLRWT
SLEEP
NOP
BTSS STUS,4
LJUMP BB4
INCR TEMP
BTSS TEMP,3
LJUMP INTRD1
LDWI 00H ;
CPIO RC
INTM1A ; TIMER1 INTERNAL COUNTER 1:1 & 1:2 & 1:4 & 1:8
LDWI 01H ;
STWR TEMP
CLRR COUNT
BCR PIR2,7
BSR STUS,5
BCR PIR2,7
BCR STUS,5
CLRWT
CLRW
CPIO RB
LDWI 0F9H ;RA0~3 OUTPUT SHOW F9H
STWR RA
CLRR T1H
CLRR T1L
TM2J
LDWI 00H
STWR T1L
BCR PIR1,0
BSR STUS,5
BSR PIR1,0
BCR STUS,5
LDWI 0C0H ;TEST INT TIMER1
STWR IRQ
LDR TEMP,0
STWR T1C
CLRR ERROR
TM1J
CLRWT
LDR T1L,0
STWR RB
BTSS ERROR,0
LJUMP TM1J
LDWI 10H
ADDWR TEMP,1
INCR COUNT,1
BTSS COUNT,2
LJUMP TM2J
INTTM1B ; TIMER1 EXTERNAL COUNTER 1:1
LDWI 07H ;
STWR TEMP
CLRR COUNT
BSR STUS,5
LDWI 00H
STWR RD
BCR STUS,5
CLRWT
LDWI 0F8H ;RA0~3 OUTPUT SHOW F8H
STWR RA
TM2BJ ; TIMER1 EXTERNAL COUNTER 1:2 NOT SYNCHRONIZE
LDWI 0E0H
STWR T1L
BCR PIR1,0
BSR STUS,5
BSR PIR1,0
BCR STUS,5
LDWI 0C0H ;TEST INT TIMER1 IN OSC1
STWR IRQ
LDR TEMP,0 ;
STWR T1C
CLRR ERROR
TM2CJ ; TIMER1 EXTERNAL COUNTER 1:2 NOT SYNCHRONIZE
CLRWT
LDR T1L,0
STWR RD
BTSS ERROR,0
LJUMP TM2CJ
LDWI 10H
ADDWR TEMP,1
INCR COUNT
BTSS COUNT,1
LJUMP TM2BJ
INTTM1C ; TIMER1 EXTERNAL COUNTER 1:4 NOT SYNCHRONIZE
LDWI 3FH
STWR TEMP
CLRR COUNT
CLRWT
LDWI 0F7H ;RA0~3 OUTPUT SHOW F7H
STWR RA
TM3BJ
LDWI 00H
STWR T1L
BCR PIR1,0
BSR STUS,5
BSR PIR1,0
BCR STUS,5
LDWI 0C0H ;TEST INT TIMER1 IN OSC1
STWR IRQ
LDR TEMP,0 ;
STWR T1C
CLRR ERROR
BB5
CLRWT
LDR T1L,0
STWR RD
BTSS ERROR,0
LJUMP BB5
LDWI 00H ;
STWR IRQ
STWR T1C
INCR TESTNO
INCR TESTNO,0
STWR RE
LCALL DELAY
LDWI 08H
STWR RCH
LJUMP PHTEST

ORG 800H

PHTEST
CLRWT
LDWI 0FFH
CPIO RA ;PA INPUT
CPIO RC ;PC INPUT
CPIO RB ;PB INPUT
BSR STUS,5
STWR RD
BCR STUS,5
INCR TESTNO
INCR TESTNO,0
STWR RE ;SHOW TEST NO.
CLRR RB
CLRR ERROR
BSR STUS,5
LDWI 80H
STWR T1C ;SET RA & RC & RD PULL_HI
BCR STUS,5
LDWI 7FH ;SET RB PULL_HI
TMODE
DKEEP
CLRWT
BTSC RA,0
LJUMP DKEEP ;
BSR STUS,5
LDWI 40H
STWR T1C ;TURN OFF RD PULL_HI
BCR STUS,5
DKEEP1
CLRWT
BTSC RA,1
LJUMP DKEEP1 ;
BSR STUS,5
LDWI 20H
STWR T1C ;TURN OFF RC PULL_HI
BCR STUS,5
DKEEP2
CLRWT
BTSC RA,2
LJUMP DKEEP2 ;
LDWI 0FFH
TMODE ;TURN OFF RB PULL_HI
DKEEP3
CLRWT
BTSC RD,0
LJUMP DKEEP3 ;
BSR STUS,5
LDWI 77H
STWR T1C ;TURN OFF RA PULL_HI
STWR RE ;SET PORT E INPUT ON PULL_HI MODE
BCR STUS,5
LDWI 00H
CPIO RA
CPIO RB
LDWI 0F0H
STWR TM1CR
BSR TM1CE,0
CLRR T1L
LDWI 31H
STWR T1C
LDWI 80H
STWR RA
DKEEP4
CLRWT
LDR T1L
STWR RB
BTSC RE,0
LJUMP DKEEP4 ;
LDWI 03H
STWR TM1CR
CLRR T1L
LDWI 03H
STWR T1C
DKEEP5
CLRWT
LDR T1L
STWR RB
BTSC RE,1
LJUMP DKEEP5 ;
LDWI 0F0H
STWR TM1CR
CLRR T1L
LDWI 2BH
STWR T1C
DKEEP6
CLRWT
LDR T1L
STWR RB
BTSC RE,2
LJUMP DKEEP6 ;
BCR TM1CE,0
LDWI 00H
STWR T1C
TSTACK
LCALL STACK1
NOP
BTSC RE,0
LJUMP TSTACK ; GOTO Test STACK
CLRR TESTNO
LDWI 00H
STWR RCH
LJUMP BEGIN ; GOTO BEGIN

ORG 0900H
STACK1
LDWI 07H
STWR ERROR
LDWI 0FFH
STWR RB
BCR STUS,CY
SLOOP1
LCALL DDELAY
RLR RB,1
DECRSZ ERROR
LJUMP SLOOP1
LCALL STACK2
RET

ORG 0A00H
STACK2
LDWI 07H
STWR ERROR
LDWI 0FEH
STWR RB
BCR STUS,CY
SLOOP2
LCALL DDELAY
RLR RB,1
DECRSZ ERROR
LJUMP SLOOP2
LCALL STACK3
RET

ORG 0B00H
STACK3
LDWI 07H
STWR ERROR
LDWI 0FCH
STWR RB
BCR STUS,CY
SLOOP3
LCALL DDELAY
RLR RB,1
DECRSZ ERROR
LJUMP SLOOP3
LCALL STACK4
RET

ORG 0C00H
STACK4
LDWI 07H
STWR ERROR
LDWI 0FFH
STWR RB
BCR STUS,CY
SLOOP4
LCALL DDELAY
RRR RB,1
DECRSZ ERROR
LJUMP SLOOP4
LCALL STACK5
RET

ORG 0D00H
STACK5
LDWI 07H
STWR ERROR
LDWI 07FH
STWR RB
BCR STUS,CY
SLOOP5
LCALL DDELAY
RRR RB,1
DECRSZ ERROR
LJUMP SLOOP5
LCALL STACK6
RET

ORG 0E00H
STACK6
LDWI 07H
STWR ERROR
LDWI 03FH
STWR RB
BCR STUS,CY
SLOOP6
LCALL DDELAY
RRR RB,1
DECRSZ ERROR
LJUMP SLOOP6
RET
ORG 0F00H
DDELAY
LDWI 0FFH
STWR DLYCNT
DLP1
LCALL DDLY
DECRSZ DLYCNT
LJUMP DLP1
RTIW 0
DDLY
CLRR DLYCT2
DDLY1
CLRWT
INCRSZ DLYCT2
LJUMP DDLY1
RTIW 55H

没有评论: