History

arm-asm: Add clz, sxtb, sxth, uxtb, uxth

Danny Milosavljevic committed 5 years ago

Commit c4e13c11 parent c9e0c2a2 files · +57 −0Browse files

Unified · Split

2 files
  1. arm-asm.c +47 −0
  2. arm-tok.h +10 −0
arm-asm.c+47−0
@@ -190,6 +190,47 @@ static void asm_unary_opcode(TCCState *s1, int token) · 189 unmodified lines
190 }190 }
191}191}
192 192
193static void asm_binary_opcode(TCCState *s1, int token)
194{
195 Operand ops[2];
196 parse_operand(s1, &ops[0]);
197 if (tok == ',')
198 next();
199 else
200 expect("','");
201 parse_operand(s1, &ops[1]);
202 if (ops[0].type != OP_REG32) {
203 expect("(destination operand) register");
204 return;
205 }
206
207 if (ops[1].type != OP_REG32)
208 expect("(source operand) register");
209 else switch (ARM_INSTRUCTION_GROUP(token)) {
210 case TOK_ASM_clzeq:
211 asm_emit_opcode(token, 0x16f0f10 | (ops[0].reg << 12) | ops[1].reg);
212 break;
213 case TOK_ASM_sxtbeq:
214 /* TODO: optional ROR (8|16|24) */
215 asm_emit_opcode(token, 0x6af0070 | (ops[0].reg << 12) | ops[1].reg);
216 break;
217 case TOK_ASM_sxtheq:
218 /* TODO: optional ROR (8|16|24) */
219 asm_emit_opcode(token, 0x6bf0070 | (ops[0].reg << 12) | ops[1].reg);
220 break;
221 case TOK_ASM_uxtbeq:
222 /* TODO: optional ROR (8|16|24) */
223 asm_emit_opcode(token, 0x6ef0070 | (ops[0].reg << 12) | ops[1].reg);
224 break;
225 case TOK_ASM_uxtheq:
226 /* TODO: optional ROR (8|16|24) */
227 asm_emit_opcode(token, 0x6ff0070 | (ops[0].reg << 12) | ops[1].reg);
228 break;
229 default:
230 expect("binary instruction");
231 }
232}
233
193static void asm_block_data_transfer_opcode(TCCState *s1, int token)234static void asm_block_data_transfer_opcode(TCCState *s1, int token)
194{235{
195 uint32_t opcode;236 uint32_t opcode;
@@ -268,6 +309,12 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 72 unmodified lines
268 return asm_nullary_opcode(token);309 return asm_nullary_opcode(token);
269 case TOK_ASM_swieq:310 case TOK_ASM_swieq:
270 return asm_unary_opcode(s1, token);311 return asm_unary_opcode(s1, token);
312 case TOK_ASM_clzeq:
313 case TOK_ASM_sxtbeq:
314 case TOK_ASM_sxtheq:
315 case TOK_ASM_uxtbeq:
316 case TOK_ASM_uxtheq:
317 return asm_binary_opcode(s1, token);
271 default:318 default:
272 expect("known instruction");319 expect("known instruction");
273 }320 }
arm-tok.h+10−0
@@ -56,6 +56,16 @@ · 55 unmodified lines
56 DEF_ASM_CONDED(wfi)56 DEF_ASM_CONDED(wfi)
57 DEF_ASM_CONDED(swi)57 DEF_ASM_CONDED(swi)
58 58
59 /* misc */
60 DEF_ASM_CONDED(clz)
61
62 /* size conversion */
63
64 DEF_ASM_CONDED(sxtb)
65 DEF_ASM_CONDED(sxth)
66 DEF_ASM_CONDED(uxtb)
67 DEF_ASM_CONDED(uxth)
68
59 /* instruction macros */69 /* instruction macros */
60 70
61 DEF_ASM_CONDED(push)71 DEF_ASM_CONDED(push)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t