Search
lxdream.org :: lxdream/src/aica/armdasm.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/aica/armdasm.c
changeset 811:7ff871670e58
prev736:a02d1475ccfd
next813:262efed79218
author nkeynes
date Wed Aug 13 10:27:49 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Implement LDRH/STRH/LDRSH/LDRSB instructions
file annotate diff log raw
1.1 --- a/src/aica/armdasm.c Mon Jul 14 07:44:42 2008 +0000
1.2 +++ b/src/aica/armdasm.c Wed Aug 13 10:27:49 2008 +0000
1.3 @@ -37,6 +37,7 @@
1.4
1.5 #define IMM8(ir) (ir&0xFF)
1.6 #define IMM12(ir) (ir&0xFFF)
1.7 +#define IMMSPLIT8(ir) (((ir&0xF00)>>4)|(ir&0x0F))
1.8 #define SHIFTIMM(ir) ((ir>>7)&0x1F)
1.9 #define IMMROT(ir) ((ir>>7)&0x1E)
1.10 #define SHIFT(ir) ((ir>>4)&0x07)
1.11 @@ -186,6 +187,30 @@
1.12 }
1.13 }
1.14
1.15 +static int arm_disasm_address3_operand( uint32_t ir, char *buf, int len, int pc )
1.16 +{
1.17 + char sign = UFLAG(ir) ? '+' : '-';
1.18 +
1.19 + switch( (ir>>21) & 0x0B) {
1.20 + case 0: /* Rn -= Rm (post-indexed) [5.3.7 A5-48] */
1.21 + case 1: /* UNPREDICTABLE */
1.22 + return snprintf( buf, len, "[R%d], R%d %c= R%d", RN(ir), RN(ir), sign, RM(ir) ) ;
1.23 + case 2: /* Rn -= imm (post-indexed) [5.3.6 A5-46] */
1.24 + case 3: /* UNPREDICTABLE */
1.25 + return snprintf( buf, len, "[R%d], R%d %c= #%04Xh", RN(ir), RN(ir), sign, IMMSPLIT8(ir) );
1.26 + case 8: /* Rn - Rm [5.3.3 A5-38] */
1.27 + return snprintf( buf, len, "[R%d %c R%d]", RN(ir), sign, RM(ir) );
1.28 + case 9: /* Rn -= Rm (pre-indexed) [5.3.5 A5-42] */
1.29 + return snprintf( buf, len, "[R%d %c= R%d]", RN(ir), sign, RM(ir) );
1.30 + case 10: /* Rn - imm offset [5.3.2 A5-36] */
1.31 + return snprintf( buf, len, "[R%d %c #%04Xh]", RN(ir), sign, IMMSPLIT8(ir) );
1.32 + case 11: /* Rn -= imm offset (pre-indexed) [5.3.4 A5-40] */
1.33 + return snprintf( buf, len, "[R%d %c= #%04Xh]", RN(ir), sign, IMMSPLIT8(ir) );
1.34 + default:
1.35 + return UNIMP(ir); /* Unreachable */
1.36 + }
1.37 +}
1.38 +
1.39 uint32_t arm_disasm_instruction( uint32_t pc, char *buf, int len, char *opcode )
1.40 {
1.41 char operand[64];
1.42 @@ -278,26 +303,28 @@
1.43 }
1.44 break;
1.45 case 1:
1.46 - if( LFLAG(ir) ) {
1.47 - /* LDRH */
1.48 - } else {
1.49 - /* STRH */
1.50 + arm_disasm_address3_operand( ir, operand, sizeof(operand), pc );
1.51 + if( LFLAG(ir) ) { /* LDRH */
1.52 + snprintf(buf, len, "LDR%sH R%d, %s", cond, RD(ir), operand );
1.53 + } else { /* STRH */
1.54 + snprintf(buf, len, "STR%sH R%d, %s", cond, RD(ir), operand );
1.55 }
1.56 - UNIMP(ir);
1.57 break;
1.58 case 2:
1.59 - if( LFLAG(ir) ) {
1.60 - /* LDRSB */
1.61 + if( LFLAG(ir) ) { /* LDRSB */
1.62 + arm_disasm_address3_operand( ir, operand, sizeof(operand), pc );
1.63 + snprintf(buf, len, "LDR%sSB R%d, %s", cond, RD(ir), operand );
1.64 } else {
1.65 + UNIMP(ir);
1.66 }
1.67 - UNIMP(ir);
1.68 break;
1.69 case 3:
1.70 - if( LFLAG(ir) ) {
1.71 - /* LDRSH */
1.72 + if( LFLAG(ir) ) { /* LDRSH */
1.73 + arm_disasm_address3_operand( ir, operand, sizeof(operand), pc );
1.74 + snprintf(buf, len, "LDR%sSH R%d, %s", cond, RD(ir), operand );
1.75 } else {
1.76 + UNIMP(ir);
1.77 }
1.78 - UNIMP(ir);
1.79 break;
1.80 }
1.81 } else {
.