📄 unasmarmdlg.cpp
字号:
sprintf (&temp[8], "%s, %s, ", RegisterName[Rd], RegisterName[Rn]);
}
}
loc = strlen (temp);
sprintf (&temp[loc], "%s, ", RegisterName[Rm]);
sft_type = (byte4 >> 5) & 3;
loc = strlen (temp);
memcpy (&temp[loc], &Sft_name[sft_type << 2], 4);
loc += 4;
if (byte4 & 0x10)
{
Rs = byte3 & 15;
sprintf (&temp[loc], "%s", RegisterName[Rs]);
}
else
{
Rs = ( (byte3 & 15) << 1) | ( (byte4 & 0x80) >> 7);
if (Rs == 0)
{
if (/*(Opcode != 13) && */sft_type)
{ // not MOV
if (sft_type == 3)
{ // ror
loc -= 4; // ror #0 -> rrx
strcpy (&temp[loc], "RRX");
}
else
strcpy (&temp[loc], "#32");
}
else
{
loc -= 6; // MOV
temp[loc] = '\0';
}
}
else
sprintf (&temp[loc], "#%d", Rs);
}
}
if (byte2 & 0x10)
{ // Set Condition codes
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
temp[5] = ( (Opcode >= 8) && (Opcode <= 11) ) ? ' ' : 'S';
}
else
{
temp[3] = ( (Opcode >= 8) && (Opcode <= 11) ) ? ' ' : 'S';
}
}
else
{
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
}
}
strcat (str, temp);
break;
case 2:
Rd = byte2 & 15;
Rn = byte3 >> 4;
Rs = byte3 & 15;
Rm = byte4 & 15;
if (byte2 & 0x20)
sprintf (temp, "MLA R%d, R%d, R%d, R%d",
Rd, Rm, Rs, Rn);
else
sprintf (temp, "MUL R%d, R%d, R%d",
Rd, Rm, Rs);
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
loc = 5;
}
else
loc = 3;
if (byte2 & 0x10)
temp[loc] = 'S';
strcat (str, temp);
break;
case 3:
RdHi = byte2 & 15;
RdLo = byte3 >> 4;
Rs = byte3 & 15;
Rm = byte4 & 15;
if (byte2 & 0x20)
{
sprintf (temp, "%cMLAL R%d, R%d, R%d, R%d",
(byte2 & 0x40) ? 'S' : 'U',
RdLo, RdHi, Rm, Rs);
}
else
{
sprintf (temp, "%cMULL R%d, R%d, R%d, R%d",
(byte2 & 0x40) ? 'S' : 'U',
RdLo, RdHi, Rm, Rs);
}
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[5] = cond_name[cond];
temp[6] = cond_name[cond+1];
loc = 7;
}
else
loc = 5;
if (byte2 & 0x10)
temp[loc] = 'S';
strcat (str, temp);
break;
case 4:
Rn = byte2 & 15;
Rd = byte3 >> 4;
Rm = byte4 & 15;
sprintf (temp, "SWP R%d, R%d, [R%d]",
Rd, Rm, Rn);
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
loc = 5;
}
else
loc = 3;
if (byte2 & 0x40)
temp[loc] = 'B';
strcat (str, temp);
break;
case 5:
Rn = byte4 & 15;
sprintf (temp, "BX %s", RegisterName[Rn]);
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[2] = cond_name[cond];
temp[3] = cond_name[cond+1];
}
strcat (str, temp);
CrLf = 1;
break;
case 6:
Rn = byte2 & 15;
Rd = byte3 >> 4;
Rm = byte4 & 15;
SH = (byte4 >> 5) & 3;
if (SH == 0)
{
strcat (str, "Bad SH!");
break;
}
SH = (SH - 1) << 3;
if (byte2 & 0x10)
{ // Load
memcpy (temp, &op_name4[SH], 8);
}
else
{ // Store
strcpy (temp, "STRH ");
}
if (byte1 & 1)
{ // Pre
sprintf (&temp[8], "R%d, [R%d, %cR%d]%c",
Rd, Rn,
(byte2 & 0x80) ? ' ' : '-', Rm,
(byte2 & 0x20) ? '!' : ' ');
}
else
{
sprintf (&temp[8], "R%d, [R%d], %cR%d",
Rd, Rn, (byte2 & 0x80) ? ' ' : '-', Rm);
}
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[6] = temp[4];
temp[5] = temp[3];
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
}
strcat (str, temp);
break;
case 7:
Rn = byte2 & 15;
Rd = byte3 >> 4;
offset = (byte4 & 15) | ( (byte3 << 4) & 0xf0);
SH = (byte4 >> 5) & 3;
if (SH == 0)
{
strcat (str, "Bad SH!");
break;
}
SH = (SH - 1) << 3;
if (byte2 & 0x10)
{ // Load
memcpy (temp, &op_name4[SH], 8);
}
else
{ // Store
strcpy (temp, "STRH ");
}
if (byte1 & 1)
{ // Pre
if (byte2 & 0x80)
{
sprintf (&temp[8], "R%d, [R%d, #0x%-x]%c",
Rd, Rn, offset, (byte2 & 0x20) ? '!' : ' ');
}
else
{
sprintf (&temp[8], "R%d, [R%d, #-0x%-x]%c",
Rd, Rn, offset, (byte2 & 0x20) ? '!' : ' ');
}
}
else
{
if (byte2 & 0x80)
{
sprintf (&temp[8], "R%d, [R%d], #0x%0x", Rd, Rn, offset);
}
else
{
sprintf (&temp[8], "R%d, [R%d], #-0x%0x", Rd, Rn, offset);
}
}
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[6] = temp[4];
temp[5] = temp[3];
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
}
strcat (str, temp);
break;
case 8:
if (byte2 & 0x10)
strcpy (temp, "LDR ");
else
strcpy (temp, "STR ");
if (byte2 & 0x40)
temp[3] = 'B';
Rn = byte2 & 15;
Rd = byte3 >> 4;
sprintf (&temp[8], "R%d, [R%d", Rd, Rn);
loc = strlen (temp);
if (byte1 & 1)
{ // Pre
if (byte1 & 2)
{ // offset is a register
temp[loc++] = ',';
temp[loc++] = ' ';
Rm = byte4 & 15;
if ( (byte2 & 0x80) == 0)
{
temp[loc++] = '-';
}
sprintf (&temp[loc], "R%d, ", Rm);
sft_type = (byte4 >> 5) & 3;
loc = strlen (temp);
memcpy (&temp[loc], &Sft_name[sft_type << 2], 4);
loc += 4;
Rs = ( (byte3 & 15) << 1) | ( (byte4 & 0x80) >> 7);
if (Rs == 0)
{
loc -= 6;
temp[loc++] = ']';
temp[loc] = '\0';
}
else
sprintf (&temp[loc], "#%d]", Rs);
}
else
{ // offset is imm value
offset = byte4 | ( (byte3 & 15) << 8);
if (Rn == 15)
{ // PC
loc -= 4;
cur_loc = ftell (fd_src);
if (byte2 & 0x80)
{
sprintf (&temp[loc], "0x%08x", addr + offset + 8);
fseek (fd_src, addr + offset + 8 - start, SEEK_SET);
}
else
{
sprintf (&temp[loc], "0x%08x", addr - offset + 8);
fseek (fd_src, addr - offset + 8 - start, SEEK_SET);
}
fread ( fourbytes, 1, 4, fd_src);
fseek (fd_src, cur_loc, SEEK_SET);
loc = strlen (temp);
if (Rd < 10)
{
if (m_Radio1)
{
sprintf (&temp[loc], " ;%02x%02x%02x%02x",
0xff & fourbytes[0],
0xff & fourbytes[1],
0xff & fourbytes[2],
0xff & fourbytes[3]);
}
else
{
sprintf (&temp[loc], " ;%02x%02x%02x%02x",
0xff & fourbytes[3],
0xff & fourbytes[2],
0xff & fourbytes[1],
0xff & fourbytes[0]);
}
}
else
{
if (m_Radio1)
{
sprintf (&temp[loc], " ;%02x%02x%02x%02x",
0xff & fourbytes[0],
0xff & fourbytes[1],
0xff & fourbytes[2],
0xff & fourbytes[3]);
}
else
{
sprintf (&temp[loc], " ;%02x%02x%02x%02x",
0xff & fourbytes[3],
0xff & fourbytes[2],
0xff & fourbytes[1],
0xff & fourbytes[0]);
}
}
if (cond < 14)
{ // Conditional
cond <<= 1;
temp[6] = temp[4];
temp[5] = temp[3];
temp[3] = cond_name[cond];
temp[4] = cond_name[cond+1];
}
strcat (str, temp);
break;
}
if (offset == 0)
{
temp[loc++] = ']';
temp[loc] = '\0';
}
else
{
if ( (byte2 & 0x80) == 0)
sprintf (&temp[loc], ", #-0x%-x]", offset);
else
sprintf (&temp[loc], ", #0x%-x]", offset);
}
}
if (byte2 & 0x20)
{ // write-back
loc = strlen (temp);
temp[loc++] = '!';
temp[loc] = '\0';
}
}
else
{ // Post
temp[loc++] = ']';
if (byte1 & 2)
{ // offset is a register
Rm = byte4 & 15;
temp[loc++] = ',';
temp[loc++] = ' ';
if ( (byte2 & 0x80) == 0)
temp[loc++] = '-';
sprintf (&temp[loc], "R%d, ", Rm);
sft_type = (byte4 >> 5) & 3;
loc = strlen (temp);
memcpy (&temp[loc], &Sft_name[sft_type << 2], 4);
loc += 4;
Rs = ( (byte3 & 15) << 1) | ( (byte4 & 0x80) >> 7);
if (Rs == 0)
{
loc -= 6;
temp[loc] = '\0';
}
else
sprintf (&temp[loc], "#%d", Rs);
}
else
{ // offset is imm value
offset = byte4 | ( (byte3 & 15) << 8);
if (offset == 0)
{
temp[loc] = '\0';
}
else
{
if ( (byte2 & 0x80) == 0)
sprintf (&temp[loc], ", #-0x%-x", offset);
else
sprintf (&temp[loc], ", #0x%-x", offset);
}
}
if (byte2 & 0x20)
{ // write-back
if (temp[3] == 'B')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -