OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [bench/] [asm/] [ivec.S] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;
3
; Filename:     ivec.S
4
;
5
; Project:      Zip CPU -- a small, lightweight, RISC CPU soft core
6
;
7
; Purpose:      Just to test whether or not a timer works as desired.  This
8
;               will set the timer to interrupt every millisecond, and then
9
;               update a counter on every interrupt.
10
;
11
;               On any failure, the processor will execute a BUSY command.
12
;
13
; Creator:      Dan Gisselquist, Ph.D.
14
;               Gisselquist Tecnology, LLC
15
;
16
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
;
18
; Copyright (C) 2015, Gisselquist Technology, LLC
19
;
20
; This program is free software (firmware): you can redistribute it and/or
21
; modify it under the terms of  the GNU General Public License as published
22
; by the Free Software Foundation, either version 3 of the License, or (at
23
; your option) any later version.
24
;
25
; This program is distributed in the hope that it will be useful, but WITHOUT
26
; ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
; for more details.
29
;
30
; License:      GPL, v3, as defined and found on www.gnu.org,
31
;               http://www.gnu.org/licenses/gpl.html
32
;
33
;
34
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35
;
36
; Registers:
37
;       sR0     Peripheral address
38
;       sR2     Interrupt controller command
39
;       sR3     Timer peripheral command
40
;       sR4     User program entry address (Could also be (re)entry address,
41
;                       but isn't in this implementation)
42
;       sR5     Whether or not we've gotten the first interrupt
43
;       sR6     Number of times we've been interrupted
44
;       sR7     Number of times R6 has overflowed
45
reset:
46
        CLR     R0              ; Load the address of the interrupt controller
47
        LDIHI   $c000h,R0       ; into R0
48
        LDI     $-1,R2          ; Acknowledge and disable all interrupts
49
        LDIHI   $7fffh,R2       ;
50
        STO     R2,(R0)         ;
51
        ; Set the timer for a programmaable interrupt, every 100k clocks,
52
        ; or roughly 1,000 times a second on a 100 MHz clock.
53
        LDIHI   $0xc001h,R3     ; R3 = 100k, save that the top two bits are
54
        LDILO   $0x86a0h,R3     ; also set (start timer, and auto reload)
55
        STO     R3,$6(C0)
56
        ; Now that timer-C is set, let's enable it's interrupts
57
        LDIHI   $8004h,R2       ; Leaving the bottom all ones acknowledges and
58
        STO     R2,(R0)         ; clears any interrupts (again)
59
        ; Clear our counter variables
60
        CLR     R5
61
        CLR     R6
62
        CLR     R7
63
        ; Program our wait for interrupt routine
64
        MOV     $8(PC),R4
65
        MOV     R4,uPC
66
        RTU
67
on_first_interrupt:
68
        ADD     $1,R5
69
setup_for_next_interrupt:
70
        RTU
71
on_subsequent_interrupt:
72
        ADD     $1,R6
73
        ADD.C   $1,R7
74
        BRA     $-4
75
haltcpu:
76
        BUSY                    ; We've failed if we ever get here
77
 
78
waitforinterrupt:
79
        WAIT
80
        BRA     $-2
81
        MOV     $0,R0
82
        MOV     $0,R0
83
        BUSY

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.