mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-24 10:06:25 +03:00
Adjust address to disassembly start
This commit is contained in:
20
src/disasm.c
20
src/disasm.c
@@ -219,7 +219,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) {
|
||||
if(Opcode == -1) {
|
||||
Pos += 2;
|
||||
} else {
|
||||
cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].mnemo);
|
||||
cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos + addr, cx->dis_op[Opcode].mnemo);
|
||||
Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8;
|
||||
}
|
||||
}
|
||||
@@ -235,7 +235,7 @@ void Disassemble(const char *Bitstream, int Read, int addr) {
|
||||
int Added;
|
||||
|
||||
// Check if this is actually code or maybe only data from tagfile
|
||||
Added = Tagfile_Process_Data(Bitstream, Pos);
|
||||
Added = Tagfile_Process_Data(Bitstream, Pos, addr);
|
||||
if(Added != 0) {
|
||||
// Data was added
|
||||
Pos += Added;
|
||||
@@ -247,22 +247,22 @@ void Disassemble(const char *Bitstream, int Read, int addr) {
|
||||
cx->dis_code[0] = 0;
|
||||
cx->dis_comment[0] = 0;
|
||||
cx->dis_after_code[0] = 0;
|
||||
cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos, cx->dis_op[Opcode].mnemo);
|
||||
cx->dis_op[Opcode].Callback(Bitstream + Pos, Pos + addr, cx->dis_op[Opcode].mnemo);
|
||||
|
||||
if(cx->dis_opts.Process_Labels) {
|
||||
Print_JumpCalls(Pos);
|
||||
Print_JumpCalls(Pos + addr);
|
||||
}
|
||||
|
||||
if(cx->dis_opts.Show_Addresses)
|
||||
printf("%4x: ", Pos);
|
||||
if(cx->dis_opts.Show_Cycles) // @@@ select correct clocks_xx
|
||||
printf("%4x: ", Pos + addr);
|
||||
if(cx->dis_opts.Show_Cycles)
|
||||
printf("[%-3s] ", avr_opcodes[cx->dis_op[Opcode].mnemo].clock[cx->dis_opts.cycle_index]);
|
||||
|
||||
if(cx->dis_opts.Show_Opcodes) {
|
||||
// Now display the Opcode
|
||||
for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++) {
|
||||
for(i = 0; i < (Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8; i++)
|
||||
printf("%02x ", (unsigned char) (Bitstream[Pos + i]));
|
||||
}
|
||||
|
||||
printf(" ");
|
||||
// Missing spaces
|
||||
for(i = 0; i < 5 - ((Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String)) / 8); i++) {
|
||||
@@ -286,8 +286,8 @@ void Disassemble(const char *Bitstream, int Read, int addr) {
|
||||
|
||||
Pos += Get_Bitmask_Length(cx->dis_op[Opcode].Opcode_String) / 8;
|
||||
} else {
|
||||
printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x (%d). Disassembler skipped two bytes.\n",
|
||||
((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos, Pos);
|
||||
printf(".word 0x%02x%02x ; Invalid opcode at 0x%04x\n", // @@@ show unoffical opcode what it might do
|
||||
((unsigned char *) Bitstream)[Pos + 1], ((unsigned char *) Bitstream)[Pos], Pos + addr);
|
||||
Pos += 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,17 +317,17 @@ const char *Tagfile_Resolve_Mem_Address(int Address) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int Tagfile_Process_Byte(const char *Bitstream, int Position, int ArgumentNo, const char *Label) {
|
||||
static int Tagfile_Process_Byte(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) {
|
||||
printf(".byte 0x%02x\n", Bitstream[Position] & 0xff);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Tagfile_Process_Word(const char *Bitstream, int Position, int ArgumentNo, const char *Label) {
|
||||
static int Tagfile_Process_Word(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) {
|
||||
printf(".word 0x%02x%02x\n", Bitstream[Position + 1] & 0xff, Bitstream[Position] & 0xff);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int Tagfile_Process_String(const char *Bitstream, int Position, int ArgumentNo, const char *Label) {
|
||||
static int Tagfile_Process_String(const char *Bitstream, int Position, int offset, int ArgumentNo, const char *Label) {
|
||||
int i;
|
||||
unsigned char c;
|
||||
unsigned int InString = 0;
|
||||
@@ -369,13 +369,13 @@ static void Sanitize_String(char *String) {
|
||||
}
|
||||
}
|
||||
|
||||
int Tagfile_Process_Data(const char *Bitstream, int Position) {
|
||||
int Tagfile_Process_Data(const char *Bitstream, int Position, int offset) {
|
||||
int BytesAdvanced;
|
||||
int Index;
|
||||
int (*ProcessingFunction)(const char *, int, int, const char *) = NULL;
|
||||
int (*ProcessingFunction)(const char *, int, int, int, const char *) = NULL;
|
||||
char Buffer[32];
|
||||
|
||||
Index = Tagfile_FindPGMAddress(Position);
|
||||
Index = Tagfile_FindPGMAddress(Position + offset);
|
||||
if(Index == -1)
|
||||
return 0;
|
||||
|
||||
@@ -411,7 +411,7 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) {
|
||||
}
|
||||
if(cx->dis_PGMLabels[Index].Count != 1)
|
||||
printf("s");
|
||||
printf(" starting at 0x%x", Position);
|
||||
printf(" starting at 0x%x", Position + offset);
|
||||
|
||||
if(cx->dis_PGMLabels[Index].Comment != NULL) {
|
||||
printf(" (%s)", cx->dis_PGMLabels[Index].Comment);
|
||||
@@ -420,16 +420,16 @@ int Tagfile_Process_Data(const char *Bitstream, int Position) {
|
||||
|
||||
if((cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) || (cx->dis_PGMLabels[Index].Type == TYPE_STRING)) {
|
||||
if(cx->dis_PGMLabels[Index].Comment != NULL) {
|
||||
snprintf(Buffer, sizeof(Buffer), "%x_%s", Position, cx->dis_PGMLabels[Index].Comment);
|
||||
snprintf(Buffer, sizeof(Buffer), "%x_%s", Position + offset, cx->dis_PGMLabels[Index].Comment);
|
||||
Sanitize_String(Buffer);
|
||||
} else {
|
||||
snprintf(Buffer, sizeof(Buffer), "%x", Position);
|
||||
snprintf(Buffer, sizeof(Buffer), "%x", Position + offset);
|
||||
}
|
||||
}
|
||||
|
||||
BytesAdvanced = 0;
|
||||
for(unsigned i = 0; i < cx->dis_PGMLabels[Index].Count; i++)
|
||||
BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, i, Buffer);
|
||||
BytesAdvanced += ProcessingFunction(Bitstream, Position + BytesAdvanced, offset, i, Buffer);
|
||||
|
||||
if(cx->dis_PGMLabels[Index].Type == TYPE_ASTRING) {
|
||||
// Autoaligned string
|
||||
|
||||
@@ -36,7 +36,7 @@ char *Tagfile_GetLabel(int TagIndex);
|
||||
char *Tagfile_GetLabelComment(int TagIndex);
|
||||
int Tagfile_FindPGMAddress(int Address);
|
||||
const char *Tagfile_Resolve_Mem_Address(int Address);
|
||||
int Tagfile_Process_Data(const char *Bitstream, int Position);
|
||||
int Tagfile_Process_Data(const char *Bitstream, int Position, int offset);
|
||||
|
||||
const char *Resolve_IO_Register(int Number);
|
||||
void Emit_Used_IO_Registers();
|
||||
|
||||
Reference in New Issue
Block a user