From c9e0c2a543f5f8ad068d8109ca7d64fbab83f7aa Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Sat, 26 Dec 2020 16:48:47 +0100 Subject: [PATCH] arm-asm: Add swi --- arm-asm.c | 21 +++++++++++++++++++++ arm-tok.h | 1 + 2 files changed, 22 insertions(+) diff --git a/arm-asm.c b/arm-asm.c index d79bf589..b6dfafea 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 82cb3dd9..db1935fb 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 */