@@ -46,7 +46,7 @@ def dref_range_fixer(startEA, endEA):
46
46
if xref .iscode or xref .frm == idc .BADADDR or str (xref .type ) != 'Data_Text' : # only try to fix data references from code in ROM of the Data_Text type (as created by the dumb seq xref routine above)
47
47
continue
48
48
logger .debug ("fixing xref (type:%s) to %s from ROM:%x" % (xref .type , safe_name (line .ea ), xref .frm ))
49
- sark .Line (xref .frm ).comments .repeat = safe_name (line .ea )
49
+ sark .Line (xref .frm ).comments .repeat = str ( sark . Line ( xref . frm ). comments . repeat ). replace ( "0x%x" % line . ea , safe_name (line .ea ) )
50
50
return
51
51
52
52
def dref_fixer ():
@@ -83,13 +83,29 @@ def avr_dumb_seq_load_xrefs(startEA, endEA):
83
83
if (is_latter_of_rxN_sequential_instructions (prev , line , 0 ) and
84
84
str (prev_insn .operands [1 ].type ) == 'Immediate_Value' and str (curr_insn .operands [1 ].type ) == 'Immediate_Value'
85
85
):
86
- word = int (curr_insn .operands [1 ].text , 0 ) * 256 + int (prev_insn .operands [1 ].text , 0 )
87
- address = ram_segment .startEA + word
88
-
89
- if address <= ram_segment .endEA :
90
- result = add_dref (line .ea , address , dr_T )
91
- logger .info ("%s adding dref to %s at 0x%x \" %s\" " % ("Success" if result else "Error" , safe_name (address ), line .ea , line ))
92
- line .comments .repeat = safe_name (address )
86
+ idc .OpHex (prev .ea , 1 )
87
+ idc .OpHex (line .ea , 1 )
88
+ if prev_insn .mnem == 'subi' and curr_insn .mnem == 'sbci' :
89
+ word = (int (curr_insn .operands [1 ].text , 0 ) + 1 ) * - 256 + int (prev_insn .operands [1 ].text , 0 ) * - 1
90
+ address = ram_segment .startEA + word
91
+
92
+ if (address > ram_segment .startEA + 0x2000 and address < ram_segment .endEA and
93
+ str (prev_insn .operands [0 ]) != 'YL' and str (prev_insn .operands [0 ].reg ) != 'r28' # ignore indexed access into stack
94
+ ):
95
+ result = add_dref (line .ea , address , dr_T )
96
+ logger .info ("%s adding dref to %s at ROM:%x \" %s\" " % ("Success" if result else "Error" , safe_name (address ), line .ea , line ))
97
+ line .comments .repeat = "indexed access into %s" % safe_name (address )
98
+ else :
99
+ word = int (curr_insn .operands [1 ].text , 0 ) * 256 + int (prev_insn .operands [1 ].text , 0 )
100
+ address = ram_segment .startEA + word
101
+
102
+ if address >= ram_segment .startEA and address < ram_segment .endEA :
103
+ result = add_dref (line .ea , address , dr_T )
104
+ logger .info ("%s adding dref to %s at ROM:%x \" %s\" " % ("Success" if result else "Error" , safe_name (address ), line .ea , line ))
105
+ if address <= ram_segment .startEA + 32 :
106
+ line .comments .repeat = "possible %s" % sark .Line (address ).comments .repeat # use the ioport name in the comments
107
+ else :
108
+ line .comments .repeat = safe_name (address )
93
109
94
110
prev = line
95
111
0 commit comments