Mercurial > hg > index.cgi
annotate lwasm/insn_inh.c @ 502:14a40f8bb4eb
Add various operators to lwcc
Add various binary and ternary operators to lwcc, but only those which can
work with constant operands. Seems like variables are probably required
next.
author | William Astle <lost@l-w.ca> |
---|---|
date | Wed, 25 Sep 2019 20:23:49 -0600 |
parents | 4fd16faa4d93 |
children |
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 | 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 | 51 l -> cycle_base = instab[l -> insn].ops[3]; |
52 } | |
376 | 53 |
385 | 54 int negq_ops[] = { 0x10, 0x43, 0x10, 0x53, 0x10, 0x31, 0xc6, 0x10, 0x31, 0xc0 }; |
55 #define negq_size (sizeof(negq_ops)/sizeof(int)) | |
56 | |
57 PARSEFUNC(insn_parse_conv) | |
58 { | |
59 int i; | |
60 l -> len = 0; | |
61 for (i = 0; i <= 2; i++) | |
62 { | |
63 if (instab[l -> insn].ops[i] >= 0) | |
64 l -> len += OPLEN(instab[l -> insn].ops[i]); | |
65 } | |
66 | |
67 /* negq */ | |
68 if (instab[l -> insn].ops[0] == -1) | |
69 l -> len = negq_size; | |
70 skip_operand(p); | |
333
507f442dc71e
Add support for 6800 compatibility instructions.
William Astle <lost@l-w.ca>
parents:
0
diff
changeset
|
71 } |
385 | 72 |
73 EMITFUNC(insn_emit_conv) | |
74 { | |
75 int i; | |
76 for (i = 0; i <= 2; i++) | |
77 { | |
78 if (instab[l -> insn].ops[i] >= 0) | |
79 lwasm_emitop(l, instab[l -> insn].ops[i]); | |
80 } | |
81 | |
82 /* special case for negq */ | |
83 if (instab[l -> insn].ops[0] == -1) | |
84 { | |
85 // 1043 (2) comd | |
86 // 1053 (2) comw | |
87 // 1031C6 (4) adcr 0,w | |
88 // 1031C0 (4) adcr 0,d | |
89 | |
90 for (i = 0; i < negq_size; i++) | |
91 lwasm_emitop(l, negq_ops[i]); | |
92 } | |
93 | |
94 l->cycle_base = instab[l -> insn].ops[3]; | |
95 } |