summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Böhm <bb@xnull.de>2009-07-06 18:15:25 +0200
committerBenedikt Böhm <bb@xnull.de>2009-07-06 18:15:25 +0200
commit8f00dd8b77df280f7456cd3dfe7a147916730434 (patch)
tree8c09fef545f99d75faea05e9d6cb7986f175511c
parentd517f267930e6c7c156bfd29f5c63bf604e9841e (diff)
downloadswppy-8f00dd8b77df280f7456cd3dfe7a147916730434.tar.gz
swppy-8f00dd8b77df280f7456cd3dfe7a147916730434.tar.xz
swppy-8f00dd8b77df280f7456cd3dfe7a147916730434.zip
fix segmentation fault on syntax error
Diffstat (limited to '')
-rw-r--r--src/emu/asm.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/emu/asm.c b/src/emu/asm.c
index 8e39202..4548b48 100644
--- a/src/emu/asm.c
+++ b/src/emu/asm.c
@@ -23,31 +23,31 @@ uint32_t compile(const char *line)
}
/* ADD, SUB, MUL, DIV, MOD, AND, OR */
- if (sscanf(line, "%s r%d, r%d, r%d", mnem, &a, &b, &c) == 4)
+ if (sscanf(line, "%4s r%d, r%d, r%d", mnem, &a, &b, &c) == 4)
return mnemonic2opc(mnem) | REGa(a) | REGb(b) | REGc(c);
/* LW, SW */
- if (sscanf(line, "%s r%d, r%d, %d", mnem, &a, &b, &c) == 4)
+ if (sscanf(line, "%4s r%d, r%d, %d", mnem, &a, &b, &c) == 4)
return mnemonic2opc(mnem) | REGa(a) | REGb(b) | IMMc(c);
/* CMP */
- if (sscanf(line, "%s r%d, r%d", mnem, &a, &b) == 3)
+ if (sscanf(line, "%4s r%d, r%d", mnem, &a, &b) == 3)
return mnemonic2opc(mnem) | REGa(a) | REGb(b);
/* MOV, BEZ */
- if (sscanf(line, "%s r%2d, %d", mnem, &a, &c) == 3)
+ if (sscanf(line, "%4s r%2d, %d", mnem, &a, &c) == 3)
return mnemonic2opc(mnem) | REGa(a) | IMMc(c);
/* EQ, NE, LT, LE, GE, GT, PUSH, POP */
- if (sscanf(line, "%s r%d", mnem, &a) == 2)
+ if (sscanf(line, "%4s r%d", mnem, &a) == 2)
return mnemonic2opc(mnem) | REGa(a);
/* JMP, CALL */
- if (sscanf(line, "%s %d", mnem, &c) == 2)
+ if (sscanf(line, "%4s %d", mnem, &c) == 2)
return mnemonic2opc(mnem) | IMMc(c);
/* RET, SYS */
- if (sscanf(line, "%s", mnem) == 1)
+ if (sscanf(line, "%4s", mnem) == 1)
return mnemonic2opc(mnem);
return 0xFFFFFFFF;