URL
https://opencores.org/ocsvn/ae18/ae18/trunk
Subversion Repositories ae18
[/] [ae18/] [trunk/] [sw/] [asm/] [ae18_core.asm] - Rev 20
Compare with Previous | Blame | View Log
;;;;;; $Id: ae18_core.asm,v 1.4 2007-10-11 18:52:24 sybreon Exp $;;;;;; Copyright (C) 2006 Shawn Tan Ser Ngiap <shawn.tan@aeste.net>;;;;;; This library is free software; you can redistribute it and/or modify it;;; under the terms of the GNU Lesser General Public License as published by;;; the Free Software Foundation; either version 2.1 of the License,;;; or (at your option) any later version.;;;;;; This library is distributed in the hope that it will be useful, but;;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public;;; License for more details.;;;;;; You should have received a copy of the GNU Lesser General Public License;;; along with this library; if not, write to the Free Software Foundation, Inc.,;;; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA;;;;;; DESCRIPTION;;; This file contains a simple test programme to test the functionality of;;; the AE18 core. It is by no means an exhaustive test. However, it does;;; perform at least each PIC18 command at least once. This file has been;;; compiled using GPASM and GPLINK.;;;;;; $Log: not supported by cvs2svn $;;;include "p18f452.inc"processor p18f452radix hex_RAM udata 0x020reg0 res 1reg1 res 1reg2 res 2_FSR udata 0x100fsr0 res 10fsr1 res 10fsr2 res 10_RESET code 0x0000goto _START_TEST_ERROR:goto $_ISRH code 0x08goto _ISRH_TEST_ISRL code 0x018goto _ISRL_TEST_MAIN code 0x0020;;;; MAIN test code loop;; Calls a series of test subroutines. Ends with a SLEEP.;;_START_TEST:;; Clear WDTclrwdtrcall _NPC_TESTrcall _LW2W_TESTrcall _BSR_TESTrcall _F2F_TESTrcall _FW2W_TESTrcall _FW2F_TESTrcall _SKIP_TESTrcall _BCC_TESTrcall _C_TESTrcall _MUL_TESTrcall _BIT_TESTrcall _N2F_TESTrcall _FSR_TESTrcall _SHA_TESTrcall _TBL_TEST;; rcall _PCL_TEST;; All tests OK!!sleep;; BUGFIX! : Two NOPs required after SLEEP command.nopnop;; RESET on wake upreset;; Infinite Loop. It should NEVER loop.bra $;;;; PCL tests - OK;; Tests to check that PCLATU/PCLATH/PCL works.;;_PCL_TEST:movlw UPPER(_PCL1)movwf PCLATUmovlw HIGH(_PCL1)movwf PCLATHmovlw LOW(_PCL1)movwf PCL ; Jumpbra $_PCL1:movlw 0xFFmovwf PCLATUmovwf PCLATHmovf PCL,W ; WREG = _PCL0_PCL0:xorlw LOW(_PCL0)bnz $movf PCLATH,Wxorlw HIGH(_PCL0)bnz $movf PCLATU,Wxorlw UPPER(_PCL0)bnz $retlw 0x00;;;; TABLE tests - OK;; Tests to check that TBLRD is working;;_TBL_TEST:clrf TBLPTRHclrf TBLPTRLtblrd*+ ; TABLAT = 10movf TABLAT,Wxorlw 0x10bnz $tblrd*+ ; TABLAT = EFmovf TABLAT,Wxorlw 0xEFbnz $retlw 0x00;;;; SHADOW test - OK;; Tests to make sure that CALL,S and RETURN,S are working;;_SHA_TEST:movlw 0xA5 ; WREG = 0xA5call _SHA0,1xorlw 0xA5 ; Z = 1bnz $retlw 0x00_SHA0:movlw 0x00 ; WREG = 0x00xorlw 0x00 ; Z = 1bnz $return 1 ; WREG = 0xA5;;;; FSR test - OK;; Uses INDF0/INDF1/INDF2 for moving values around;;_FSR_TEST:lfsr 2,fsr2lfsr 1,fsr1lfsr 0,fsr0movlw 0xA5movwf INDF0 ; FSR2 = A5movff fsr0,reg0 ; REG2 = FSR2xorwf reg0,W ; Z = 1bnz $movlw 0xB6movwf INDF1movff fsr1,reg1xorwf reg1,Wbnz $movlw 0xC7movwf INDF2movff fsr2,reg2xorwf reg2,Wbnz $retlw 0x00;;;; SETF/NEGF/CLRF tests - OK;; Miscellaneous mono op operations;;_N2F_TEST:clrf reg0 ; Z = 1, N = 0movf reg0,Fbnz $bn $setf reg0 ; Z = 0, N = 1movf reg0,Fbz $bnn $negf reg0 ; REG0 = 0x01movf reg0,Fbz $bn $retlw 0x00;;;; BCC test - OK;; Tests all the Z/N/C/OV conditional branches for;; positive and negative results;;_BCC_TEST:;; Positive testsmovlw 0x01movwf reg0 ; REG0 = 0x01rrcf reg0,W ; C = 1, WREG = 0x00bc $+4bra $rlcf reg0,W ; C = 0, WREG = 0x02bnc $+4bra $andlw 0x00 ; Z = 1bz $+4bra $iorlw 0x01 ; Z = 0bnz $+4bra $xorlw 0x81 ; N = 1bn $+4bra $xorlw 0x80 ; N = 0bnn $+4bra $;; Negative testmovlw 0x00 ; WREG = 0addlw 0x00 ; WREG = 0, C = 0iorlw 0xFF ; Z = 0, N = 1bz $bnn $bc $addlw 0x01 ; C = 1, Z = 1, N = 0bnc $bnz $bn $;; Test OVmovlw 0x80addlw 0x80 ; C = 1, OV = 1, N = 0, Z = 1bnov $bov $+4bra $retlw 0x00;;;; BSR test - OK;; Simple test to check that BSR is working;;_BSR_TEST:movlw 0xA5 ; WREG = 0xA5movlb 0x02 ; BSR = 0x02movwf 0x00,B ; (0x0200) = 0xA5movff 0x0200, 0x0000 ; (0x0000) = 0xA5swapf 0x0000,W ; WREG = 0x5A;xorlw 0x5A ; WREG = 0, Z = 1bnz $retlw 0x00;;;; C used instruction tests;; Tests a series of instructions that use C;; TODO - verify_C_TEST:movlw 0xFF ; Indicate Startmovlw 0x00addlw 0x00 ; C = 0movwf reg2 ; REG2 = 0movlw 0x80 ; WREG = 0x80, C = 0addlw 0x80 ; WREG = 0x00, C = 1rrcf reg2,W ; WREG = 0x80, C = 0;addlw 0x80 ; WREG = 0x00, C = 1;rlcf reg2,W ; WREG = 0x01, C = 0;addlw 0xFF ; WREG = 0x00, C = 1;addwfc reg2,W ; WREG = 0x01, C = 0;subwfb reg2,W ; WREG = 0xFE, C = 1;addwfc reg2,W ; WREG = 0xFF, C = 0;subfwb reg2,W ; WREG = 0xFE, C = 0;retlw 0x00;;;; SKIP tests - OK;; Tests the various SNZ/SZ/SEQ/SGT/SLT instructions;;_SKIP_TEST:movlw 0x01 ; WREG = 0x01movwf reg0 ; REG0 = 0x01btfss reg0,0bra $btfsc reg0,1bra $decfsz reg0,f ; REG0 = 0x00bra $dcfsnz reg0,f ; REG0 = 0xFFbra $incfsz reg0,f ; REG0 = 0x00bra $infsnz reg0,f ; REG0 = 0x01bra $cpfseq reg0bra $movlw 0x02cpfslt reg0bra $movlw 0x00 ; WREG = 0x00cpfsgt reg0bra $movlw 0x00movwf reg2tstfsz reg2bra $retlw 0x00;;;; FILE * WREG => FILE tests - OK;; Tests the series of byte file operations;;_FW2F_TEST:movlw 0xA5 ; WREG = 0xA5movwf reg2 ; REG2 = 0xA5swapf reg2,F ; REG2 = 0x5Aandwf reg2,F ; REG2 = 0x00iorwf reg2,F ; REG2 = 0xA5xorwf reg2,F ; REG2 = 0x00addwf reg2,F ; REG2 = 0xA5subwf reg2,F ; REG2 = 0x00movwf reg2 ; REG2 = 0xA5rrncf reg2,F ; REG2 = 0xD2rlncf reg2,F ; REG2 = 0xA5comf reg2,F ; REG2 = 0x5Aincf reg2,F ; REG2 = 0x5Bdecf reg2,F ; REG2 = 0x5Axorwf reg2,W ; WREG = 0xFFxorlw 0xFFbnz $retlw 0x00;;;; FILE * WREG => WREG test - OK;; Tests the series of byte file operations;;_FW2W_TEST:movlw 0xA5 ; WREG = 0xA5movwf reg2 ; REG2 = 0xA5swapf reg2,W ; WREG = 0x5Aandwf reg2,W ; WREG = 0x00iorwf reg2,W ; WREG = 0xA5xorwf reg2,W ; WREG = 0x00addwf reg2,W ; WREG = 0xA5subwf reg2,W ; WREG = 0x00rrncf reg2,W ; WREG = 0xD2rlncf reg2,W ; WREG = 0x4Bcomf reg2,W ; WREG = 0x5Aincf reg2,W ; WREG = 0xA6decf reg2,W ; WREG = 0xA4xorlw 0xA4bnz $retlw 0x00 ; WREG = 0x0;;;; MOVE FILE=>WREG/FILE=>FILE/WREG=>FILE tests - OK;; Tests moves between FILE and WREG;;_F2F_TEST:movlw 0xA5 ; WREG = 0xA5movwf reg0 ; REG0 = 0xA5movlw 0x00 ; WREG = 0x00movff reg0,reg1 ; REG1 = 0xA5movf reg0,f ; REG0 = 0xA5movf reg1,w ; WREG = 0xA5xorlw 0xA5bnz $retlw 0x00;;;; BIT test - OK;; Tests the sequence of BIT ops;;_BIT_TEST:movlw 0xA5 ; WREG = 0xA5movwf reg2 ; REG2 = 0xA5bcf reg2,0 ;movf reg2,W ; WREG = 0xA4bsf reg2,0 ;movf reg2,W ; WREG = 0xA5btg reg2,0 ;movf reg2,W ; WREG = 0xA4xorlw 0xA4 ; Z = 1bnz $retlw 0x00;;;; LIT * WREG => WREG tests - OK;; Tests that the sequence of literal operations;;_LW2W_TEST:movlw 0xA5 ; WREG = 0xA5addlw 0x05 ; WREG = 0xAAsublw 0xFF ; WREG = 0x55andlw 0xF0 ; WREG = 0x50iorlw 0x0A ; WREG = 0x5Axorlw 0xFF ; WREG = 0xA5xorlw 0xA5bnz $retlw 0x00 ; WREG = 0x00;;;; NEAR test - OK;; Tests the ability to perform BRA and RCALL by doing some;; jump acrobatics.;;_NPC_TEST:bra _NTFWDgoto $ ; Forward Jump_NTFWD: bra _NTBWD_NTRET: returngoto $_NTBWD: bra _NTRET ; Backward Jumpgoto $;;;; MULLW/MULWF tests - OK;; Tests that the multiplier produces the correct results;;_MUL_TEST:movlw 0x0A ; WREG = 0x0Amovwf reg0 ; REG0 = 0x0Amullw 0xA0 ; PRODH,PRODL = 0x0640movf PRODH,W ; Z = 0xorlw 0x06 ; Z = 1bnz $movf PRODL,W ; Z = 0xorlw 0x40 ; Z = 1bnz $movlw 0x40 ; WREG = 0x40mulwf reg0 ; PRODH,PRODL = 0x0280movf PRODH,W ; Z = 0xorlw 0x02 ; Z = 1bnz $movf PRODL,W ; Z = 0xorlw 0x80 ; Z = 1bnz $retlw 0x00;;;; Interrupt Response Test - OK;; Just check to see if it jumps here and returns correctly.;;_ISRH_TEST:_ISRL_TEST:nop ; Do somethingretfie 1;; Add some NOP at the end to avoid simulation error;; due to XXXX content at memory locations outside;; of the end of the programme.nopnopnopnopnopnopnopnopnopend
