arm-asm: Add cdp2

Also allow instructions without condition code in the first place
This commit is contained in:
Danny Milosavljevic 2021-01-12 23:48:54 +01:00
parent 036a7fe7d4
commit a1dad7a9f7
No known key found for this signature in database
GPG Key ID: E71A35542C30BAA5
3 changed files with 21 additions and 6 deletions

View File

@ -155,7 +155,7 @@ ST_FUNC void gen_expr32(ExprValue *pe)
static uint32_t condition_code_of_token(int token) {
if (token < TOK_ASM_nopeq) {
expect("instruction");
expect("condition-enabled instruction");
return 0;
} else
return (token - TOK_ASM_nopeq) & 15;
@ -335,6 +335,7 @@ static void asm_coprocessor_opcode(TCCState *s1, int token) {
Operand opcode2;
uint8_t registers[3];
unsigned int i;
uint8_t high_nibble;
if (tok >= TOK_ASM_p0 && tok <= TOK_ASM_p15) {
coprocessor = tok - TOK_ASM_p0;
@ -380,7 +381,11 @@ static void asm_coprocessor_opcode(TCCState *s1, int token) {
return;
}
asm_emit_coprocessor_opcode(condition_code_of_token(token), coprocessor, opcode1.e.v, registers[0], registers[1], registers[2], opcode2.e.v, 0);
if (token == TOK_ASM_cdp2)
high_nibble = 0xF;
else
high_nibble = condition_code_of_token(token);
asm_emit_coprocessor_opcode(high_nibble, coprocessor, opcode1.e.v, registers[0], registers[1], registers[2], opcode2.e.v, 0);
}
/* data processing and single data transfer instructions only */
@ -1426,10 +1431,15 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
}
if (token == TOK_EOF)
return;
if (token < TOK_ASM_nopeq) {
if (token < TOK_ASM_nopeq) { // no condition code
switch (token) {
case TOK_ASM_cdp2:
return asm_coprocessor_opcode(s1, token);
default:
expect("instruction");
return;
}
}
switch (ARM_INSTRUCTION_GROUP(token)) {
case TOK_ASM_pusheq:

View File

@ -70,6 +70,10 @@
DEF_ASM(asl)
/* instructions that have no condition code */
DEF_ASM(cdp2)
#define ARM_INSTRUCTION_GROUP(tok) ((((tok) - TOK_ASM_nopeq) & 0xFFFFFFF0) + TOK_ASM_nopeq)
/* Note: condition code is 4 bits */

View File

@ -5,7 +5,7 @@ set -e
# Note: "{r3}" is definitely different--but would complicate the assembler.
state="`mktemp -d`"
cat ../arm-tok.h |grep DEF_ASM_CONDED |grep -v '#define' |grep -v '/[*]' |sed -e 's;DEF_ASM_CONDED.\(.*\).$;\1;'| grep -v 'not useful' | while read s
cat ../arm-tok.h |grep DEF_ASM |grep -v 'not useful' |grep -v '#define' |grep -v '/[*]' |sed -e 's;^[ ]*DEF_ASM[^(]*(\(.*\)).*$;\1;' | egrep -v '^((r|c|p)[0-9]+|fp|ip|sp|lr|pc|asl)$' | while read s
do
ok=0
for args in "r3, r4, r5, r6" \
@ -90,6 +90,7 @@ do
"r4, #0xFFFFFF00" \
"r2, #-4" \
"p10, #7, c2, c0, c1, #4" \
"p10, #7, r2, c0, c1, #4" \
"#4" \
"#-4" \
""