URL
https://opencores.org/ocsvn/zipcpu/zipcpu/trunk
Subversion Repositories zipcpu
[/] [zipcpu/] [trunk/] [bench/] [asm/] [testdiv.S] - Rev 69
Compare with Previous | Blame | View Log
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Filename: testdiv.S;; Project: Zip CPU -- a small, lightweight, RISC CPU soft core;; Purpose: Tests the libraries signed division algorithm.;; Creator: Dan Gisselquist, Ph.D.; Gisselquist Technology, LLC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Copyright (C) 2015, Gisselquist Technology, LLC;; This program is free software (firmware): you can redistribute it and/or; modify it under the terms of the GNU General Public License as published; by the Free Software Foundation, either version 3 of the License, or (at; your option) any later version.;; This program is distributed in the hope that it will be useful, but WITHOUT; ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License; for more details.;; License: GPL, v3, as defined and found on www.gnu.org,; http://www.gnu.org/licenses/gpl.html;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Registers:; R12 Peripheral base; R11 Address of our one memory variable;/* something else */#include "sys.i"start:LDI 0xc0000000,R12 ; Get the address of our peripheral baseMOV $1(PC),R11 ; Get a memory address for a variableBRA skip_test_variabletest_variable:WORD 0skip_test_variable:LDI $-1,R0 ; Start the watchdog timerSTO R0,sys.bus.wdt(R12)LSR $1,R0 ; R0 now = 0x7fffffffSTO R0,sys.bus.tma(R12)LSR $1,R0 ; R0 now = 0x3fffffffSTO R0,sys.bus.tmb(R12)LSR $1,R0STO R0,sys.bus.tmc(R12);CLR R0wdt_test_loop:ADD $1,R0LOD (R11),R1CMP R0,R1STO.LT R0,(R11)TST -1,R0BLT wdt_test_program_is_brokenBRA wdt_test_loopwdt_test_program_is_broken:HALTentry:; Set up a test programMOV test_div_program(PC),uPCMOV top_of_stack(PC),uSP; Run it in user spaceRTU; Check for how the result came back: R0 = 0 means successMOV uR11,R11TST -1,R11HALT.ZBUSYtest_div_program:;LDI 1,R11LDI 5,R0LDI 1,R1LDI 5,R2LDI 0,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 2,R11LDI 5,R0LDI 2,R1LDI 2,R2LDI 1,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 3,R11LDI 0xb53d0,R0LDI 0x2d,R1LDI 16496,R2LDI 32,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 4,R11LDI 2031890191,R0LDI 120193795,R1LDI 16,R2LDI 108789471,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 5,R11LDI 203553,R0LDI 142580994,R1LDI 0,R2LDI 203553,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 6,R11LDI 142580994,R0LDI 203553,R1LDI 700,R2LDI 93894,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 7,R11LDI 142580994,R0LDI 2499,R1LDI 57055,R2LDI 549,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 8,R11LDI -142580994,R0LDI 2499,R1LDI -57055,R2LDI -549,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 9,R11LDI 142580994,R0LDI -2499,R1LDI -57055,R2LDI 549,R3MOV __HERE__+2(PC),R4BRA test_divs;LDI 10,R11LDI -142580994,R0LDI -2499,R1LDI 57055,R2LDI -549,R3MOV __HERE__+2(PC),R4BRA test_divs;CLR R11TRAP 0test_divs:; R0 = Numerator; R1 = Denominator; R2 = Integer result; R3 = Remainder; R4 = Return address; R11= Test failure IDMOV R2,R5MOV R3,R6MOV __HERE__+2(PC),R2BRA lib_divsCMP R0,R5BNZ test_failureCMP R1,R6BNZ test_failureJMP R4test_failure:TRAP 0NOOPBUSY
