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