URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
[/] [amber/] [trunk/] [hw/] [tests/] [change_mode.S] - Rev 2
Compare with Previous | Blame | View Log
/*****************************************************************// //// Amber 2 Core Instruction Test //// //// This file is part of the Amber project //// http://www.opencores.org/project,amber //// //// Description //// Tests teq, tst, cmp and cmn with the p flag set //// Starts in supervisor mode, changes to Interrupt mode, //// then Fast Interrupt mode, then supervisor mode again //// and finally User mode //// //// Author(s): //// - Conor Santifort, csantifort.amber@gmail.com //// ////////////////////////////////////////////////////////////////////// //// Copyright (C) 2010 Authors and OPENCORES.ORG //// //// This source file may be used and distributed without //// restriction provided that this copyright statement is not //// removed from the file and that any derivative work contains //// the original copyright notice and the associated disclaimer. //// //// This source file 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 source 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 source; if not, download it //// from http://www.opencores.org/lgpl.shtml //// //*****************************************************************/#include "amber_registers.h".section .text.globl mainmain:@ ------------------------------------------------------------@ Change to Interrupt mode using tstp@ tstp does an ANDmov r4, #0xfffffffe@ When the pc is in the rn position, it includes the status bitststp r4, pc@ Check that we're now in Interrupt modemov r5, pc@ just want the mode bitsand r5, r5, #0x3cmp r5, #2movne r10, #50bne testfail@ ------------------------------------------------------------@ Change to Fast Interrupt mode using cmpp@ cmpp does a subtractmov r6, pccmpp r6, #1mov r7, pcand r8, r7, #3cmp r8, #1movne r10, #60bne testfail@ ------------------------------------------------------------@ Change back to Supervisor mode using cmnp@ cmnp does an addldr r1, Status1cmnp pc, #0xf0000003nopmov r9, pcldr r0, PCMaskbic r13, r9, r0cmp r13, r1movne r10, #70bne testfail@ ------------------------------------------------------------@ Clear all the status bits and change to user mode@ teq does an XORteqp pc, #0b 1fb testfailb testfail@ Check that all the status bits are now zero1: ldr r0, PCMaskmov r1, pcbics r1, r1, r0movne r10, #10bne testfail@ ------------------------------------------------------------@ Now in user mode, so can't change back to supervisor mode@ But can set the condition flagsteqp pc, #0xf0000003mov r2, #0orr r1, r2, pcbic r1, r1, r0cmp r1, #0xf0000000movne r10, #20bne testfailb testpasstestfail:ldr r11, AdrTestStatusstr r10, [r11]b testfailtestpass:ldr r11, AdrTestStatusmov r10, #17str r10, [r11]b testpass/* Write 17 to this address to generate a Test Passed message */AdrTestStatus: .word ADR_AMBER_TEST_STATUSPCMask: .word 0x03fffffcStatus1: .word 0xf0000003/* ========================================================================= *//* ========================================================================= */
