URL
https://opencores.org/ocsvn/amber/amber/trunk
Subversion Repositories amber
[/] [amber/] [trunk/] [hw/] [tests/] [change_sbits.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 movs where the destination register is r15, the pc //// Depending on the processor mode and whether the s bit is //// set or not, some or none of the status bits will change. //// //// 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:@ ------------------------------------------------------------------------@ In supervisor mode, change to user modeldr r0, UserMode@ set the condition flagsorr r0, r0, #0xf0000000@ set one of the interrupt masksorr r0, r0, #0x04000000ldr r1, =1fldr r2, PCMaskand r2, r1, r2orr r3, r2, r0movs pc, r3@ Check that the jump works correctlyb testfailb testfail1: b 2fb testfailb testfail@ Now check that the status bits are changed correctly2: mov r8, pcldr r9, PCMaskbic r9, r8, r9ldr r12, ExpectedBits1cmp r9, r12movne r10, #20bne testfail@ ------------------------------------------------------------------------@ Test that in user mode, only the condition status bit@ and the pc can be changed@ In User mode, change to Supervisor mode (this isn't allowed and will fail)ldr r0, SupervisorMode@ set the condition flagsorr r0, r0, #0x30000000@ set one of the interrupt masksorr r0, r0, #0x08000000ldr r1, =3fldr r2, PCMaskand r2, r1, r2orr r3, r2, r0movs pc, r3@ Check that the jump works correctlyb testfailb testfail3: b 4fb testfailb testfail@ Now check that the status bits are changed correctly4: mov r8, pcldr r9, PCMaskbic r9, r8, r9ldr r12, ExpectedBits2cmp r9, r12movne r10, #30bne testfail@ ------------------------------------------------------------------------@ Test that in user mode, only the pc changes when the s bit is not setmov r12, pc @ remeber the current pc status bitsldr r9, PCMaskbic r12, r12, r9ldr r0, UserMode@ set the condition flagsorr r0, r0, #0xc0000000ldr r1, =5fldr r2, PCMaskand r2, r1, r2orr r3, r2, r0mov pc, r3@ Check that the jump works correctlyb testfailb testfail5: b 6fb testfailb testfail@ Now check that the status bits are not changed6: mov r8, pcldr r9, PCMaskbic r9, r8, r9cmp r9, r12movne r10, #40bne 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_STATUS/* Switch to user mode */UserMode: .word 0x00000000SupervisorMode: .word 0x00000003PCMask: .word 0x03fffffcExpectedBits1: .word 0xf4000000ExpectedBits2: .word 0x34000000ExpectedBits3: .word 0x34000000/* ========================================================================= *//* ========================================================================= */
