Mercurial > hg > index.cgi
changeset 387:2abcd82b455f
Make TFM complain if invalid registers are used
TFM can only accept 5 pointer registers as source/dest. Complain if anything
else is used.
Thanks to Erik G <erik@6809.org> for the patch.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 13 Jul 2015 21:33:54 -0600 |
parents | 221b5f58d8ad |
children | f813a56178c0 |
files | lwasm/insn_tfm.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/insn_tfm.c Mon Jul 13 21:32:39 2015 -0600 +++ b/lwasm/insn_tfm.c Mon Jul 13 21:33:54 2015 -0600 @@ -34,7 +34,7 @@ c = strchr(reglist, toupper(*(*p)++)); if (!c) { - lwasm_register_error(as, l, E_UNKNOWN_OPERATION); + lwasm_register_error(as, l, E_REGISTER_BAD); return; } r0 = c - reglist; @@ -56,7 +56,7 @@ c = strchr(reglist, toupper(*(*p)++)); if (!c) { - lwasm_register_error(as, l, E_UNKNOWN_OPERATION); + lwasm_register_error(as, l, E_REGISTER_BAD); return; } r1 = c - reglist; @@ -77,7 +77,13 @@ lwasm_register_error(as, l, E_OPERAND_BAD); return; } - + /* only D, X, Y, U, S are valid tfm registers */ + if (r0 > 4 || r1 > 4) + { + if (r0 < r1) r0 = r1; + lwasm_register_error2(as, l, E_REGISTER_BAD, "'%c'", reglist[r0]); + } + // valid values of tfm here are: // 1: r0+,r1 (2) // 4: r0,r1+ (3)