[PATCH 1/1] arm-asm: Add movt

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/1] arm-asm: Add movt

Danny Milosavljevic
---
 arm-asm.c | 15 ++++++++++++++-
 arm-tok.h |  1 +
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arm-asm.c b/arm-asm.c
index 6eb680a..1aeb28c 100644
--- a/arm-asm.c
+++ b/arm-asm.c
@@ -226,7 +226,19 @@ static void asm_binary_opcode(TCCState *s1, int token)
         tcc_warning("Using 'sp' as operand with '%s' is deprecated by ARM", get_tok_str(token, NULL));
 
     if (ops[1].type != OP_REG32) {
-        expect("(source operand) register");
+        switch (ARM_INSTRUCTION_GROUP(token)) {
+        case TOK_ASM_movteq:
+            if (ops[1].type == OP_IM8 || ops[1].type == OP_IM8N || ops[1].type == OP_IM32) {
+                if (ops[1].e.v >= 0 && ops[1].e.v <= 0xFFFF)
+                    asm_emit_opcode(token, 0x3400000 | (ops[0].reg << 12) | ops[1].e.v);
+                else
+                    expect("(source operand) immediate 16 bit value");
+            } else
+                expect("(source operand) immediate");
+            break;
+        default:
+            expect("(source operand) register");
+        }
         return;
     }
 
@@ -1120,6 +1132,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
     case TOK_ASM_sxtheq:
     case TOK_ASM_uxtbeq:
     case TOK_ASM_uxtheq:
+    case TOK_ASM_movteq:
         return asm_binary_opcode(s1, token);
 
     case TOK_ASM_ldreq:
diff --git a/arm-tok.h b/arm-tok.h
index 6d2483b..626e20e 100644
--- a/arm-tok.h
+++ b/arm-tok.h
@@ -69,6 +69,7 @@
  DEF_ASM_CONDED(sxth)
  DEF_ASM_CONDED(uxtb)
  DEF_ASM_CONDED(uxth)
+ DEF_ASM_CONDED(movt)
 
  /* multiplication */
 

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH v2] arm-asm: Add movt

Danny Milosavljevic
---
 arm-asm.c | 16 +++++++++++++++-
 arm-tok.h |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arm-asm.c b/arm-asm.c
index 6eb680a..cec1700 100644
--- a/arm-asm.c
+++ b/arm-asm.c
@@ -226,7 +226,20 @@ static void asm_binary_opcode(TCCState *s1, int token)
         tcc_warning("Using 'sp' as operand with '%s' is deprecated by ARM", get_tok_str(token, NULL));
 
     if (ops[1].type != OP_REG32) {
-        expect("(source operand) register");
+        switch (ARM_INSTRUCTION_GROUP(token)) {
+        case TOK_ASM_movteq:
+            if (ops[1].type == OP_IM8 || ops[1].type == OP_IM8N || ops[1].type == OP_IM32) {
+                if (ops[1].e.v >= 0 && ops[1].e.v <= 0xFFFF) {
+                    uint16_t immediate_value = ops[1].e.v;
+                    asm_emit_opcode(token, 0x3400000 | (ops[0].reg << 12) | (immediate_value & 0xF000) << 4 | (immediate_value & 0xFFF));
+                } else
+                    expect("(source operand) immediate 16 bit value");
+            } else
+                expect("(source operand) immediate");
+            break;
+        default:
+            expect("(source operand) register");
+        }
         return;
     }
 
@@ -1120,6 +1133,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
     case TOK_ASM_sxtheq:
     case TOK_ASM_uxtbeq:
     case TOK_ASM_uxtheq:
+    case TOK_ASM_movteq:
         return asm_binary_opcode(s1, token);
 
     case TOK_ASM_ldreq:
diff --git a/arm-tok.h b/arm-tok.h
index 6d2483b..626e20e 100644
--- a/arm-tok.h
+++ b/arm-tok.h
@@ -69,6 +69,7 @@
  DEF_ASM_CONDED(sxth)
  DEF_ASM_CONDED(uxtb)
  DEF_ASM_CONDED(uxth)
+ DEF_ASM_CONDED(movt)
 
  /* multiplication */
 

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel