Mercurial > hg > index.cgi
diff lwasm/insn_inh.c @ 385:4fd16faa4d93
Add various "convenience" ops
These are things like "NEGD" in 6809 mode or NEGQ in 6309 mode. These
require either 6809conv or 6309conv pragmas.
Also fix a problem with "CPX" in the 6800 mode.
Thanks to Erik G <erik@6809.org> for the patch.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 13 Jul 2015 21:26:34 -0600 |
parents | 35d4213e6657 |
children |
line wrap: on
line diff
--- a/lwasm/insn_inh.c Mon Jul 13 21:20:30 2015 -0600 +++ b/lwasm/insn_inh.c Mon Jul 13 21:26:34 2015 -0600 @@ -39,6 +39,7 @@ l -> len = OPLEN(instab[l -> insn].ops[0]); if (instab[l -> insn].ops[1] >= 0) l -> len += OPLEN(instab[l -> insn].ops[1]); + skip_operand(p); } EMITFUNC(insn_emit_inh6800) @@ -47,6 +48,48 @@ lwasm_emitop(l, instab[l -> insn].ops[0]); if (instab[l -> insn].ops[1] >= 0) lwasm_emitop(l, instab[l -> insn].ops[1]); + l -> cycle_base = instab[l -> insn].ops[3]; +} - l -> cycle_adj = instab[l -> insn].ops[3]; +int negq_ops[] = { 0x10, 0x43, 0x10, 0x53, 0x10, 0x31, 0xc6, 0x10, 0x31, 0xc0 }; +#define negq_size (sizeof(negq_ops)/sizeof(int)) + +PARSEFUNC(insn_parse_conv) +{ + int i; + l -> len = 0; + for (i = 0; i <= 2; i++) + { + if (instab[l -> insn].ops[i] >= 0) + l -> len += OPLEN(instab[l -> insn].ops[i]); + } + + /* negq */ + if (instab[l -> insn].ops[0] == -1) + l -> len = negq_size; + skip_operand(p); } + +EMITFUNC(insn_emit_conv) +{ + int i; + for (i = 0; i <= 2; i++) + { + if (instab[l -> insn].ops[i] >= 0) + lwasm_emitop(l, instab[l -> insn].ops[i]); + } + + /* special case for negq */ + if (instab[l -> insn].ops[0] == -1) + { + // 1043 (2) comd + // 1053 (2) comw + // 1031C6 (4) adcr 0,w + // 1031C0 (4) adcr 0,d + + for (i = 0; i < negq_size; i++) + lwasm_emitop(l, negq_ops[i]); + } + + l->cycle_base = instab[l -> insn].ops[3]; +} \ No newline at end of file