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

Subversion Repositories zipcpu

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

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

powered by: WebSVN 2.1.0

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