tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] [PATCH 09/16] arm-asm: Add swi


From: Danny Milosavljevic
Subject: [Tinycc-devel] [PATCH 09/16] arm-asm: Add swi
Date: Sat, 26 Dec 2020 22:58:10 +0100

---
 arm-asm.c | 21 +++++++++++++++++++++
 arm-tok.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/arm-asm.c b/arm-asm.c
index d79bf58..b6dfafe 100644
--- a/arm-asm.c
+++ b/arm-asm.c
@@ -171,6 +171,25 @@ static void asm_nullary_opcode(int token)
     }
 }
 
+static void asm_unary_opcode(TCCState *s1, int token)
+{
+    Operand op;
+    parse_operand(s1, &op);
+
+    switch (ARM_INSTRUCTION_GROUP(token)) {
+    case TOK_ASM_swieq:
+        if (op.type != OP_IM8)
+            expect("immediate 8-bit unsigned integer");
+        else {
+            /* Note: Dummy operand (ignored by processor): ARM ref documented 
0...255, ARM instruction set documented 24 bit */
+            asm_emit_opcode(token, (0xf << 24) | op.e.v);
+        }
+        break;
+    default:
+        expect("unary instruction");
+    }
+}
+
 static void asm_block_data_transfer_opcode(TCCState *s1, int token)
 {
     uint32_t opcode;
@@ -247,6 +266,8 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
     case TOK_ASM_wfeeq:
     case TOK_ASM_wfieq:
         return asm_nullary_opcode(token);
+    case TOK_ASM_swieq:
+        return asm_unary_opcode(s1, token);
     default:
         expect("known instruction");
     }
diff --git a/arm-tok.h b/arm-tok.h
index 82cb3dd..db1935f 100644
--- a/arm-tok.h
+++ b/arm-tok.h
@@ -54,6 +54,7 @@
  DEF_ASM_CONDED(nop)
  DEF_ASM_CONDED(wfe)
  DEF_ASM_CONDED(wfi)
+ DEF_ASM_CONDED(swi)
 
  /* instruction macros */
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]