arm-asm: Add cdp2
Also allow instructions without condition code in the first place
This commit is contained in:
parent
036a7fe7d4
commit
a1dad7a9f7
3 changed files with 21 additions and 6 deletions
20
arm-asm.c
20
arm-asm.c
|
@ -155,7 +155,7 @@ ST_FUNC void gen_expr32(ExprValue *pe)
|
||||||
|
|
||||||
static uint32_t condition_code_of_token(int token) {
|
static uint32_t condition_code_of_token(int token) {
|
||||||
if (token < TOK_ASM_nopeq) {
|
if (token < TOK_ASM_nopeq) {
|
||||||
expect("instruction");
|
expect("condition-enabled instruction");
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
return (token - TOK_ASM_nopeq) & 15;
|
return (token - TOK_ASM_nopeq) & 15;
|
||||||
|
@ -335,6 +335,7 @@ static void asm_coprocessor_opcode(TCCState *s1, int token) {
|
||||||
Operand opcode2;
|
Operand opcode2;
|
||||||
uint8_t registers[3];
|
uint8_t registers[3];
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
uint8_t high_nibble;
|
||||||
|
|
||||||
if (tok >= TOK_ASM_p0 && tok <= TOK_ASM_p15) {
|
if (tok >= TOK_ASM_p0 && tok <= TOK_ASM_p15) {
|
||||||
coprocessor = tok - TOK_ASM_p0;
|
coprocessor = tok - TOK_ASM_p0;
|
||||||
|
@ -380,7 +381,11 @@ static void asm_coprocessor_opcode(TCCState *s1, int token) {
|
||||||
return;
|
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 */
|
/* data processing and single data transfer instructions only */
|
||||||
|
@ -1426,9 +1431,14 @@ ST_FUNC void asm_opcode(TCCState *s1, int token)
|
||||||
}
|
}
|
||||||
if (token == TOK_EOF)
|
if (token == TOK_EOF)
|
||||||
return;
|
return;
|
||||||
if (token < TOK_ASM_nopeq) {
|
if (token < TOK_ASM_nopeq) { // no condition code
|
||||||
expect("instruction");
|
switch (token) {
|
||||||
return;
|
case TOK_ASM_cdp2:
|
||||||
|
return asm_coprocessor_opcode(s1, token);
|
||||||
|
default:
|
||||||
|
expect("instruction");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ARM_INSTRUCTION_GROUP(token)) {
|
switch (ARM_INSTRUCTION_GROUP(token)) {
|
||||||
|
|
|
@ -70,6 +70,10 @@
|
||||||
|
|
||||||
DEF_ASM(asl)
|
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)
|
#define ARM_INSTRUCTION_GROUP(tok) ((((tok) - TOK_ASM_nopeq) & 0xFFFFFFF0) + TOK_ASM_nopeq)
|
||||||
|
|
||||||
/* Note: condition code is 4 bits */
|
/* Note: condition code is 4 bits */
|
||||||
|
|
|
@ -5,7 +5,7 @@ set -e
|
||||||
# Note: "{r3}" is definitely different--but would complicate the assembler.
|
# Note: "{r3}" is definitely different--but would complicate the assembler.
|
||||||
|
|
||||||
state="`mktemp -d`"
|
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
|
do
|
||||||
ok=0
|
ok=0
|
||||||
for args in "r3, r4, r5, r6" \
|
for args in "r3, r4, r5, r6" \
|
||||||
|
@ -90,6 +90,7 @@ do
|
||||||
"r4, #0xFFFFFF00" \
|
"r4, #0xFFFFFF00" \
|
||||||
"r2, #-4" \
|
"r2, #-4" \
|
||||||
"p10, #7, c2, c0, c1, #4" \
|
"p10, #7, c2, c0, c1, #4" \
|
||||||
|
"p10, #7, r2, c0, c1, #4" \
|
||||||
"#4" \
|
"#4" \
|
||||||
"#-4" \
|
"#-4" \
|
||||||
""
|
""
|
||||||
|
|
Loading…
Reference in a new issue