annotate lwasm/insn_inh.c @ 569:37014b2935bf lwtools-4.22

Bump version in preparation for release
author William Astle <lost@l-w.ca>
date Fri, 22 Dec 2023 21:03:18 -0700
parents 4fd16faa4d93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
1 /*
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
2 insn_inh.c
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
3 Copyright © 2010 William Astle
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
4
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
5 This file is part of LWASM.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
6
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
10 version.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
11
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
15 more details.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
16
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
19
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
20 */
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
21
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
22 #include "lwasm.h"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
23 #include "instab.h"
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
24
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
25 PARSEFUNC(insn_parse_inh)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
26 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
27 l -> len = OPLEN(instab[l -> insn].ops[0]);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
28 skip_operand(p);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
29 }
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
30
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
31 EMITFUNC(insn_emit_inh)
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
32 {
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
33 lwasm_emitop(l, instab[l -> insn].ops[0]);
2c24602be78f Initial import from lwtools 3.0.1 version, with new hand built build system and file reorganization
lost@l-w.ca
parents:
diff changeset
34 }
333
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
35
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
36 PARSEFUNC(insn_parse_inh6800)
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
37 {
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
38 // there may be two operations here so check for both
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
39 l -> len = OPLEN(instab[l -> insn].ops[0]);
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
40 if (instab[l -> insn].ops[1] >= 0)
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
41 l -> len += OPLEN(instab[l -> insn].ops[1]);
385
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
42 skip_operand(p);
333
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
43 }
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
44
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
45 EMITFUNC(insn_emit_inh6800)
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
46 {
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
47 // there may be two operations here so check for both
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
48 lwasm_emitop(l, instab[l -> insn].ops[0]);
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
49 if (instab[l -> insn].ops[1] >= 0)
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
50 lwasm_emitop(l, instab[l -> insn].ops[1]);
385
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
51 l -> cycle_base = instab[l -> insn].ops[3];
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
52 }
376
35d4213e6657 Add cycle counting to listing
William Astle <lost@l-w.ca>
parents: 333
diff changeset
53
385
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
54 int negq_ops[] = { 0x10, 0x43, 0x10, 0x53, 0x10, 0x31, 0xc6, 0x10, 0x31, 0xc0 };
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
55 #define negq_size (sizeof(negq_ops)/sizeof(int))
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
56
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
57 PARSEFUNC(insn_parse_conv)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
58 {
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
59 int i;
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
60 l -> len = 0;
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
61 for (i = 0; i <= 2; i++)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
62 {
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
63 if (instab[l -> insn].ops[i] >= 0)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
64 l -> len += OPLEN(instab[l -> insn].ops[i]);
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
65 }
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
66
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
67 /* negq */
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
68 if (instab[l -> insn].ops[0] == -1)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
69 l -> len = negq_size;
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
70 skip_operand(p);
333
507f442dc71e Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents: 0
diff changeset
71 }
385
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
72
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
73 EMITFUNC(insn_emit_conv)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
74 {
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
75 int i;
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
76 for (i = 0; i <= 2; i++)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
77 {
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
78 if (instab[l -> insn].ops[i] >= 0)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
79 lwasm_emitop(l, instab[l -> insn].ops[i]);
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
80 }
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
81
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
82 /* special case for negq */
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
83 if (instab[l -> insn].ops[0] == -1)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
84 {
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
85 // 1043 (2) comd
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
86 // 1053 (2) comw
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
87 // 1031C6 (4) adcr 0,w
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
88 // 1031C0 (4) adcr 0,d
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
89
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
90 for (i = 0; i < negq_size; i++)
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
91 lwasm_emitop(l, negq_ops[i]);
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
92 }
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
93
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
94 l->cycle_base = instab[l -> insn].ops[3];
4fd16faa4d93 Add various "convenience" ops
William Astle <lost@l-w.ca>
parents: 376
diff changeset
95 }