URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [tests/] [or1200/] [sim/] [or1200-cy.S] - Rev 530
Compare with Previous | Blame | View Log
/*OR1200 carry bit checkingCarry generated on all adds which we interpret to beunsigned. The CPU will generate both CY and OV.CY is generated when unsigned values generate an extra bit.OV is when the values, interpreted as signed, cannot havethe result displayed as it is too large.OV is not checked here. Just CY generation and inclusion bythe l.addc and l.addic instructions.Very basic, testing.TODO: Substraction carry out testing.Julius Baxter, ORSoC AB, julius.baxter@orsoc.se*/////////////////////////////////////////////////////////////////////////// //////// Copyright (C) 2011 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 "spr-defs.h"#include "board.h"#include "or1200-defines.h"/* =================================================== [ exceptions ] === */.section .vectors, "ax"/* ---[ 0x100: RESET exception ]----------------------------------------- */.org 0x100l.movhi r0, 0/* Clear status register */l.ori r1, r0, SPR_SR_SMl.mtspr r0, r1, SPR_SR/* Clear timer */l.mtspr r0, r0, SPR_TTMR/* Jump to program initialisation code */.global _startl.movhi r4, hi(_start)l.ori r4, r4, lo(_start)l.jr r4l.nop.org 0x600l.nop 0x1/* ---[ 0x700: Illegal instruction exception ]-------------------------- */.org 0x700#ifndef OR1200_IMPL_ADDC// No problem - instruction not supportedl.movhi r3, hi(0x8000000d)l.ori r3, r3, lo(0x8000000d)l.nop 0x2l.ori r3, r0, 0#elsel.ori r3, r0, 1#endifl.nop 0x1/* ---[ 0xb00: Range exception ]---------------------------------------- */.org 0xb00l.sw 0(r0), r3l.ori r3, r0, 0xaaeel.nop 0x2l.lwz r3, 0(r0)l.rfe/* =================================================== [ text ] === */.section .text/* =================================================== [ start ] === */.global _start_start:// Clear regsl.movhi r1, 0l.movhi r2, 0l.movhi r3, 0l.movhi r4, 0l.movhi r5, 0l.movhi r6, 0#ifdef OR1200_IMPL_CY// Kick off testl.jal _main#else// Not supported, exit testl.j _finish#endifl.nop/* =================================================== [ main ] === */#define CHECK_CY_CLEAR \l.mfspr r6, r0, SPR_SR ; \l.andi r6, r6, SPR_SR_CY ; \l.sfne r6, r0 ; \l.bf _fail ; \l.nop#define CHECK_CY_SET \l.mfspr r6, r0, SPR_SR ; \l.andi r6, r6, SPR_SR_CY ; \l.sfnei r6, SPR_SR_CY ; \l.bf _fail ; \l.nop.global _main_main:// Set up some values, check the CY bit is cleared from resetCHECK_CY_CLEAR// A large unsigned valuel.movhi r4, 0xffffl.ori r4, r4, 0xefff// A value large enough to cause carryl.ori r5, r0, 0x1001l.add r3, r5, r4 ;// Should set CYl.nop 0x2CHECK_CY_SETl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEARl.addi r3, r4, 0x1001 ;// Should set CYl.nop 0x2CHECK_CY_SETl.addi r3, r4, 0x1000 ;// Shouldn't set CYl.nop 0x2CHECK_CY_CLEARl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEAR// Check use of carry - l.addcl.addi r3, r4, 0x1001 ;// Should set CY;; // Consequtive instructionsl.addc r3, r3, r5 ;// r3 should be 0x1002l.nop 0x2 ;// Reportl.sfnei r3, 0x1002l.bf _faill.nopl.add r3, r4, r5 ;// Should set CYl.nop ;// 1 delay instructionl.addc r3, r3, r5 ;// r3 should be 0x1002l.nop 0x2 ;// Reportl.sfnei r3, 0x1002l.bf _faill.nopl.add r3, r4, r5 ;// Should setl.nop 0x2 ;// 1 delay instructionl.nop ;// 2nd delay instructionl.addc r3, r3, r5 ;// r3 should be 0x1002l.nop 0x2 ;// Reportl.sfnei r3, 0x1002l.bf _faill.nopl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEAR// Check use of carry - l.addicl.addi r3, r4, 0x1001 ;// Should set CY;; // Consequtive instructionsl.addic r3, r3, 0x1 ;// r3 should be 2l.nop 0x2 ;// Reportl.sfnei r3, 0x2l.bf _faill.nopl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEARl.add r3, r4, r5 ;// Should set CYl.nop ;// 1 delay instructionl.addic r3, r3, 0x1 ;// r3 should be 2l.nop 0x2 ;// Reportl.sfnei r3, 0x2l.bf _faill.nopl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEARl.add r3, r4, r5 ;// Should setl.nop 0x2 ;// 1 delay instructionl.nop ;// 2nd delay instructionl.addic r3, r3, 0x1 ;// r3 should be 2l.nop 0x2 ;// Reportl.sfnei r3, 0x2l.bf _faill.nopl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEAR// Add with carry and generate carry with l.addcl.add r3, r4, r5l.addc r3, r4, r5l.nop 0x2l.sfnei r3, 0x1l.bf _faill.nopCHECK_CY_SETl.add r3, r0, r0 ;// Should clear CYCHECK_CY_CLEAR// Add with carry and generate carry with l.addicl.addi r3, r4, 0x1001l.addic r3, r4, 0x1001l.nop 0x2l.sfnei r3, 0x1l.bf _faill.nopCHECK_CY_SET_finish:l.movhi r3, hi(0x8000000d)l.ori r3, r3, lo(0x8000000d)l.nop 0x2l.ori r3, r0, 0l.nop 0x1_fail:l.ori r3, r0, 1l.nop 0x1
