aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--asm.peg8
-rw-r--r--main.c18
-rw-r--r--minias.h1
-rw-r--r--test/test.sh13
4 files changed, 40 insertions, 0 deletions
diff --git a/asm.peg b/asm.peg
index b2dbaae..a2e90b1 100644
--- a/asm.peg
+++ b/asm.peg
@@ -77,6 +77,7 @@ instr =
| i:mul { $$ = i; }
# Less common, but we have already checked for 'm'
| i:movaps { $$ = i; }
+ | i:movq { $$ = i; }
| i:movsd { $$ = i; }
| i:movss { $$ = i; }
| i:mulsd { $$ = i; }
@@ -492,6 +493,13 @@ movsd = "movsd" (
| ws s:xmm ws? ',' ws? d:mem { $$ = INSTR2(2, s, d); }
) { $$.instr.kind = ASM_MOVSD; }
+movq = "mov" (
+ 'q'? ws s:xmm ws? ',' ws? d:r64 { $$ = INSTR2(0, s, d); }
+ | 'q'? ws s:r64 ws? ',' ws? d:xmm { $$ = INSTR2(1, s, d); }
+ | 'q' ws s:xmm ws? ',' ws? d:mem { $$ = INSTR2(2, s, d); }
+ | 'q' ws s:mem ws? ',' ws? d:xmm { $$ = INSTR2(3, s, d); }
+) { $$.instr.kind = ASM_MOVQ; }
+
ucomiss = "ucomiss" (
ws s:xmm ws? ',' ws? d:xmm { $$ = INSTR2(0, s, d); }
| ws s:mem ws? ',' ws? d:xmm { $$ = INSTR2(1, s, d); }
diff --git a/main.c b/main.c
index 7b310c5..c5e2e96 100644
--- a/main.c
+++ b/main.c
@@ -943,6 +943,24 @@ static void assemble(void) {
case ASM_MOV:
assemblemov(&v->instr);
break;
+ case ASM_MOVQ:
+ switch (v->instr.variant) {
+ case 0:
+ assemblerrm(&v->instr, 0x66, 0x01000f7e, 0);
+ break;
+ case 1:
+ assemblerrm(&v->instr, 0x66, 0x01000f6e, 1);
+ break;
+ case 2:
+ assemblerrm(&v->instr, 0x66, 0x01000fd6, 0);
+ break;
+ case 3:
+ assemblerrm(&v->instr, 0xf3, 0x01000f7e, 1);
+ break;
+ default:
+ unreachable();
+ }
+ break;
case ASM_MOVSD:
assemblemovsmmx(&v->instr, 0xf2);
break;
diff --git a/minias.h b/minias.h
index 3f89ef0..d4b1f48 100644
--- a/minias.h
+++ b/minias.h
@@ -88,6 +88,7 @@ typedef enum {
ASM_IMUL,
ASM_MOV,
ASM_MOVAPS,
+ ASM_MOVQ,
ASM_MOVSD,
ASM_MOVSS,
ASM_MOVSX,
diff --git a/test/test.sh b/test/test.sh
index 84b14d5..0a89b61 100644
--- a/test/test.sh
+++ b/test/test.sh
@@ -30,6 +30,17 @@ t () {
echo -n "."
}
+for r in rax r10
+do
+ for x in xmm0 xmm13
+ do
+ t "movq %${x}, %${r}"
+ t "movq %${r}, %${x}"
+ t "movq %${x}, (%${r})"
+ t "movq (%${r}), %${x}"
+ done
+done
+
t "movl \$1000, %r8d"
t "movb %sil, (%rdi)"
@@ -259,6 +270,8 @@ t "movb \$127, (%rbp)"
t "movb \$127, 2147483647(%rsp)"
t "movb \$127, 2147483647(%rbp)"
+
+
for x in s z
do
t "mov${x}bw %al, %bx"