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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [optest.cpp] - Blame information for rev 10

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

Line No. Rev Author Line
1 2 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    optest.cpp
4
//
5
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
6
//
7
// Purpose:     A quick test of whether we can decode opcodes properly.
8
//
9
// Creator:     Dan Gisselquist, Ph.D.
10
//              Gisselquist Tecnology, LLC
11
//
12
////////////////////////////////////////////////////////////////////////////////
13
//
14
// Copyright (C) 2015, Gisselquist Technology, LLC
15
//
16
// This program is free software (firmware): you can redistribute it and/or
17
// modify it under the terms of  the GNU General Public License as published
18
// by the Free Software Foundation, either version 3 of the License, or (at
19
// your option) any later version.
20
//
21
// This program is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License along
27
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
28
// target there if the PDF file isn't present.)  If not, see
29
// <http://www.gnu.org/licenses/> for a copy.
30
//
31
// License:     GPL, v3, as defined and found on www.gnu.org,
32
//              http://www.gnu.org/licenses/gpl.html
33
//
34
//
35
////////////////////////////////////////////////////////////////////////////////
36
#include <stdio.h>
37
 
38
#include "zopcodes.h"
39
 
40
 
41
void    optest(const ZIPI ins) {
42
        char    line[512];
43
 
44
        zipi_to_string(ins, line);
45
        printf("0x%08x ->\t%s\n", ins, line);
46
}
47
 
48
int main(int argc, char **argv) {
49
        char    line[512];
50
 
51
        optest(0x00000000);     // CMP $0,R0
52
        optest(0x0f000000);     // CMP $0,PC
53
        optest(0x0e0fffff);     // CMP $-1,CC
54
        optest(0x2f007fff);     // MOV $-1+R0,PC -> JMP $-1+R0
55
        optest(0x2f0f7fff);     // MOV $-1+PC,PC -> BRA $-1
56
        optest(0x2f2f7fff);     // BRZ $-1+R0
57
        optest(0x2f4fffff);     // MOV.NE $-1+uPC,PC
58
        optest(0xbe000010);     // HALT
59
        optest(0xbe000020);     // RTU
60
        optest(0x9e00005f);     // INT
61
        optest(0xc6160000);     // CLR R6
62
        optest(0xcf1f0000);     // CLR R6
63
        optest(0xce1e0000);     // CLR CC
64
        optest(0xcd1d0000);     // CLR SP
65
        optest(0xc71e0000);     // XOR CC,R7
66
        optest(0x2f0f7fff);     // BRA $-1
67
        optest(0x2f2f7fff);     // BRZ $-1
68
        optest(0x2f4f7fff);     // BNE $-1
69
        optest(0xa0000000);     // ADD $0,R0
70
        optest(0xaf030350);     // ADD $0x197456,PC -> LJMP $197456+PC
71
        optest(0xaf230350);     // ADD.Z $0x197456,PC -> LJMP.Z $197456+PC
72
        optest(0x4e000000);     // NOOP
73
        optest(0x4f000000);     // LODILO $0,R0
74
        optest(0x4f00ffff);     // LODILO $0,R0
75
        optest(0x4f057fff);     // LODILO $0,R5
76
        optest(0x4f0c0001);     // LODILO $0,R12
77
        optest(0x4f1d0001);     // LODIHI $0,SP
78
        optest(0x601f0007);     // LOD ($7+PC),R0
79
        optest(0x60df000f);     // LOD.C $15(PC),R0
80
        optest(0x6cff003f);     // LOD.V $63(PC),R12
81
        optest(0x701f0007);     // STO R0,($7+PC)
82
        optest(0x70000007);     // STO R0,($7)
83
        optest(0x701f0000);     // STO R0,(PC)
84
 
85
        optest(0xc0100000);     // CLR R0
86
        optest(0x21000000);     // MOV R0,R1
87
        optest(0x22000001);     // MOV $1+$0,R2
88
        optest(0x23000002);     // MOV $2+$0,R3
89
        optest(0x24000022);     // MOV $22h+$0,R4
90
        optest(0x25100377);     // MOV $337h+$0,uR5
91
 
92
}
93
 

powered by: WebSVN 2.1.0

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