;/////////////////////////////////////////////////////////////////////
|
;/////////////////////////////////////////////////////////////////////
|
;//// ////
|
;//// ////
|
;//// Mini-RISC-1 ////
|
;//// Mini-RISC-1 ////
|
;//// Compliance Test 2 ////
|
;//// Compliance Test 2 ////
|
;//// Tests PLC register Rd/Wr ////
|
;//// Tests PLC register Rd/Wr ////
|
;//// ////
|
;//// ////
|
;//// Author: Rudolf Usselmann ////
|
;//// Author: Rudolf Usselmann ////
|
;//// russelmann@hotmail.com ////
|
;//// russelmann@hotmail.com ////
|
;//// ////
|
;//// ////
|
;/////////////////////////////////////////////////////////////////////
|
;/////////////////////////////////////////////////////////////////////
|
;//// ////
|
;//// ////
|
;//// Copyright (C) 2000 Rudolf Usselmann ////
|
;//// Copyright (C) 2000 Rudolf Usselmann ////
|
;//// russelmann@hotmail.com ////
|
;//// russelmann@hotmail.com ////
|
;//// ////
|
;//// ////
|
;//// This source file may be used and distributed without ////
|
;//// This source file may be used and distributed without ////
|
;//// restriction provided that this copyright statement is not ////
|
;//// restriction provided that this copyright statement is not ////
|
;//// removed from the file and that any derivative work contains ////
|
;//// removed from the file and that any derivative work contains ////
|
;//// the original copyright notice and the associated disclaimer.////
|
;//// the original copyright notice and the associated disclaimer.////
|
;//// ////
|
;//// ////
|
;//// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY ////
|
;//// THIS SOURCE FILE IS PROVIDED "AS IS" AND WITHOUT ANY ////
|
;//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT ////
|
;//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT ////
|
;//// LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND ////
|
;//// LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND ////
|
;//// FITNESS FOR A PARTICULAR PURPOSE. ////
|
;//// FITNESS FOR A PARTICULAR PURPOSE. ////
|
;//// ////
|
;//// ////
|
;/////////////////////////////////////////////////////////////////////
|
;/////////////////////////////////////////////////////////////////////
|
|
|
list p=16c57
|
list p=16c57
|
#include p16c5x.inc
|
#include p16c5x.inc
|
|
|
; global Registers
|
; global Registers
|
r0 equ 0x8
|
r0 equ 0x8
|
r1 equ 0x9
|
r1 equ 0x9
|
r2 equ 0xa
|
r2 equ 0xa
|
r3 equ 0xb
|
r3 equ 0xb
|
r4 equ 0xc
|
r4 equ 0xc
|
r5 equ 0xd
|
r5 equ 0xd
|
r6 equ 0xe
|
r6 equ 0xe
|
r7 equ 0xf
|
r7 equ 0xf
|
|
|
; banked Registers
|
; banked Registers
|
br0 equ 0x10
|
br0 equ 0x10
|
br1 equ 0x11
|
br1 equ 0x11
|
br2 equ 0x12
|
br2 equ 0x12
|
br3 equ 0x13
|
br3 equ 0x13
|
br4 equ 0x14
|
br4 equ 0x14
|
br5 equ 0x15
|
br5 equ 0x15
|
br6 equ 0x16
|
br6 equ 0x16
|
br7 equ 0x17
|
br7 equ 0x17
|
br8 equ 0x18
|
br8 equ 0x18
|
br9 equ 0x19
|
br9 equ 0x19
|
br10 equ 0x1a
|
br10 equ 0x1a
|
br11 equ 0x1b
|
br11 equ 0x1b
|
br12 equ 0x1c
|
br12 equ 0x1c
|
br13 equ 0x1d
|
br13 equ 0x1d
|
br14 equ 0x1e
|
br14 equ 0x1e
|
br15 equ 0x1f
|
br15 equ 0x1f
|
|
|
|
|
; PORTB Indicates Test Number
|
; PORTB Indicates Test Number
|
; PORTA Indicates Status: 0 - Running; 1 - done OK; ff - stoped on error
|
; PORTA Indicates Status: 0 - Running; 1 - done OK; ff - stoped on error
|
|
|
main ; Main code entry
|
main ; Main code entry
|
; Port IO Test
|
; Port IO Test
|
; All ports have a Pull up resistor
|
; All ports have a Pull up resistor
|
|
|
; SETUP all ports
|
; SETUP all ports
|
clrw
|
clrw
|
movwf FSR
|
movwf FSR
|
movwf PORTA
|
movwf PORTA
|
movwf PORTB
|
movwf PORTB
|
movwf PORTC
|
movwf PORTC
|
tris PORTA
|
tris PORTA
|
tris PORTB
|
tris PORTB
|
tris PORTC
|
tris PORTC
|
|
|
; -------------------------------
|
; -------------------------------
|
; ---- Test the PLC register ----
|
; ---- Test the PLC register ----
|
; -------------------------------
|
; -------------------------------
|
|
|
; PLC read test 1 TEST 0
|
; PLC read test 1 TEST 0
|
|
|
movlw pclrd1
|
movlw pclrd1
|
movwf r0
|
movwf r0
|
movf PCL,W
|
movf PCL,W
|
pclrd1 subwf r0,W
|
pclrd1 subwf r0,W
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
; PLC read test 2 TEST 1
|
; PLC read test 2 TEST 1
|
movlw 0x01
|
movlw 0x01
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
movlw pclrd2
|
movlw pclrd2
|
movwf r3
|
movwf r3
|
movf PCL,W
|
movf PCL,W
|
pclrd2 subwf r3,W
|
pclrd2 subwf r3,W
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
; PLC write test 2 TEST 2
|
; PLC write test 2 TEST 2
|
movlw 0x02
|
movlw 0x02
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
movlw pclwr1
|
movlw pclwr1
|
movwf PCL
|
movwf PCL
|
|
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
pclwr1 goto pcl1
|
pclwr1 goto pcl1
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
|
|
pcl1
|
pcl1
|
; PLC write test 2 TEST 3
|
; PLC write test 2 TEST 3
|
movlw 0x03
|
movlw 0x03
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
movlw pclwr2
|
movlw pclwr2
|
movwf PCL
|
movwf PCL
|
|
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
pclwr2 goto pcl2
|
pclwr2 goto pcl2
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
|
|
pcl2 ; Test other instructions that modify PC
|
pcl2 ; Test other instructions that modify PC
|
; This are ADDWF PC, BSF PC,X and BCF PC,X
|
; This are ADDWF PC, BSF PC,X and BCF PC,X
|
; (movwf pc already tested above)
|
; (movwf pc already tested above)
|
|
|
; PLC write test 3 TEST 4
|
; PLC write test 3 TEST 4
|
; test addwf PC
|
; test addwf PC
|
movlw 0x04
|
movlw 0x04
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
movlw pcl3b
|
movlw pcl3b
|
movwf r0
|
movwf r0
|
movlw pcl3a
|
movlw pcl3a
|
subwf r0,W
|
subwf r0,W
|
pcl3a addwf PCL,1
|
pcl3a addwf PCL,1
|
|
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
pcl3b goto lerr
|
pcl3b goto lerr
|
goto pcl3c
|
goto pcl3c
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
pcl3c
|
pcl3c
|
|
|
; PLC write test 4 TEST 5
|
; PLC write test 4 TEST 5
|
; test addwf PC
|
; test addwf PC
|
movlw 0x05
|
movlw 0x05
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
movlw pcl4b
|
movlw pcl4b
|
movwf br8
|
movwf br8
|
movlw pcl4a
|
movlw pcl4a
|
subwf br8,W
|
subwf br8,W
|
pcl4a addwf PCL,1
|
pcl4a addwf PCL,1
|
|
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
pcl4b goto lerr
|
pcl4b goto lerr
|
goto pcl4c
|
goto pcl4c
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
pcl4c
|
pcl4c
|
|
|
; PLC write test 5 TEST 6
|
; PLC write test 5 TEST 6
|
; test bsf PC,N
|
; test bsf PC,N
|
movlw 0x06
|
movlw 0x06
|
movwf PORTB ; Set Test N
|
movwf PORTB ; Set Test N
|
|
|
; allign memory
|
; allign memory
|
goto pcl50
|
goto pcl50
|
|
|
pcl50 org 0x60
|
pcl50 org 0x60
|
|
|
bsf PCL,1 ; 60
|
bsf PCL,1 ; 60
|
goto lerr ; 61
|
goto lerr ; 61
|
goto lerr ; 62
|
goto lerr ; 62
|
goto pcl5a ; 63
|
goto pcl5a ; 63
|
goto lerr ; 64
|
goto lerr ; 64
|
goto lerr ; 65
|
goto lerr ; 65
|
goto lerr ; 66
|
goto lerr ; 66
|
goto lerr ; 67
|
goto lerr ; 67
|
|
|
pcl5a
|
pcl5a
|
|
|
; PLC write test 6 TEST 7
|
; PLC write test 6 TEST 7
|
; test bsf PC,N
|
; test bsf PC,N
|
movlw 0x07
|
movlw 0x07
|
movwf PORTB ; Set Test N
|
movwf PORTB ; Set Test N
|
|
|
bsf PCL,2 ; 6A
|
bsf PCL,2 ; 6A
|
goto lerr ; 6B
|
goto lerr ; 6B
|
goto lerr ; 6C
|
goto lerr ; 6C
|
goto lerr ; 6D
|
goto lerr ; 6D
|
goto lerr ; 6E
|
goto lerr ; 6E
|
goto pcl6a ; 6F
|
goto pcl6a ; 6F
|
goto lerr ; 70
|
goto lerr ; 70
|
goto lerr ; 71
|
goto lerr ; 71
|
|
|
pcl6a
|
pcl6a
|
|
|
; PLC write test 7 TEST 8
|
; PLC write test 7 TEST 8
|
; test bcf PC,N
|
; test bcf PC,N
|
movlw 0x08
|
movlw 0x08
|
movwf PORTB ; Set Test N
|
movwf PORTB ; Set Test N
|
|
|
goto pcl7a ; 74
|
goto pcl7a ; 74
|
goto lerr ; 75
|
goto lerr ; 75
|
goto lerr ; 76
|
goto lerr ; 76
|
goto lerr ; 77
|
goto lerr ; 77
|
goto lerr ; 78
|
goto lerr ; 78
|
goto pcl7b ; 79
|
goto pcl7b ; 79
|
goto lerr ; 7a
|
goto lerr ; 7a
|
goto lerr ; 7b
|
goto lerr ; 7b
|
|
|
pcl7a
|
pcl7a
|
bcf PCL,2 ; 7c
|
bcf PCL,2 ; 7c
|
|
|
pcl7b
|
pcl7b
|
|
|
|
|
; Make sure goto works
|
; Make sure goto works
|
movlw 0x09 ; TEST 9
|
movlw 0x09 ; TEST 9
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
|
|
goto gt1
|
goto gt1
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
movlw 0xff
|
movlw 0xff
|
movwf PORTA
|
movwf PORTA
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
gt1
|
gt1
|
|
|
; Make sure call works
|
; Make sure call works
|
movlw 0x0a ; TEST 10
|
movlw 0x0a ; TEST 10
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
call cal1
|
call cal1
|
movwf r0
|
movwf r0
|
movlw 0x55
|
movlw 0x55
|
subwf r0,w
|
subwf r0,w
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
call cal2
|
call cal2
|
movwf r0
|
movwf r0
|
movlw 0xaa
|
movlw 0xaa
|
subwf r0,w
|
subwf r0,w
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
call cal3
|
call cal3
|
movwf r0
|
movwf r0
|
movlw 0xc3
|
movlw 0xc3
|
subwf r0,w
|
subwf r0,w
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
call cal4
|
call cal4
|
movwf r0
|
movwf r0
|
movlw 0x3c
|
movlw 0x3c
|
subwf r0,w
|
subwf r0,w
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
goto next1
|
goto next1
|
|
|
cal1
|
cal1
|
retlw 0x55
|
retlw 0x55
|
goto lerr
|
goto lerr
|
|
|
cal2
|
cal2
|
nop
|
nop
|
retlw 0xaa
|
retlw 0xaa
|
goto lerr
|
goto lerr
|
|
|
cal3
|
cal3
|
nop
|
nop
|
nop
|
nop
|
retlw 0xc3
|
retlw 0xc3
|
goto lerr
|
goto lerr
|
|
|
cal4
|
cal4
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
retlw 0x3c
|
retlw 0x3c
|
goto lerr
|
goto lerr
|
|
|
table1
|
table1
|
addwf PCL,F
|
addwf PCL,F
|
retlw 0xff
|
retlw 0xff
|
retlw 0xfe
|
retlw 0xfe
|
retlw 0xfd
|
retlw 0xfd
|
retlw 0xfc
|
retlw 0xfc
|
retlw 0xfb
|
retlw 0xfb
|
retlw 0xfa
|
retlw 0xfa
|
retlw 0xf9
|
retlw 0xf9
|
retlw 0xf8
|
retlw 0xf8
|
retlw 0xf7
|
retlw 0xf7
|
retlw 0xf6
|
retlw 0xf6
|
retlw 0xf5
|
retlw 0xf5
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
goto lerr
|
|
|
next1
|
next1
|
|
|
|
|
; Make sure call works (2)
|
; Make sure call works (2)
|
movlw 0x0b ; TEST 11
|
movlw 0x0b ; TEST 11
|
movwf PORTB ; Set Test Number
|
movwf PORTB ; Set Test Number
|
|
|
movlw 0x0
|
movlw 0x0
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x1
|
movlw 0x1
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x2
|
movlw 0x2
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x3
|
movlw 0x3
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x4
|
movlw 0x4
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x5
|
movlw 0x5
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x6
|
movlw 0x6
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x7
|
movlw 0x7
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x8
|
movlw 0x8
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0x9
|
movlw 0x9
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
movlw 0xa
|
movlw 0xa
|
movwf r0
|
movwf r0
|
call table1
|
call table1
|
comf r0,F
|
comf r0,F
|
subwf r0,F
|
subwf r0,F
|
btfss STATUS,Z
|
btfss STATUS,Z
|
goto lerr
|
goto lerr
|
|
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
movlw 0x01
|
movlw 0x01
|
movwf PORTA
|
movwf PORTA
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
good ; Loop in good on success
|
good ; Loop in good on success
|
goto good
|
goto good
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
|
|
lerr
|
lerr
|
movlw 0xff
|
movlw 0xff
|
movwf PORTA
|
movwf PORTA
|
|
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
lerr_loop ; Loop in lerr on failure
|
lerr_loop ; Loop in lerr on failure
|
goto lerr_loop
|
goto lerr_loop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
nop
|
|
|
END
|
END
|
|
|
|
|