@@ -87,7 +87,7 @@ class M6502(Architecture):
8787 flags = [c_flag , z_flag , i_flag , d_flag , b_flag , v_flag , s_flag ]
8888 flag_write_types = [FlagWriteTypeName ("*" ), FlagWriteTypeName ("czs" ), FlagWriteTypeName ("zvs" ),FlagWriteTypeName ( "zs" )]
8989 flag_roles = {
90- c_flag : FlagRole .SpecialFlagRole , # Not a normal carry flag, subtract result is inverted
90+ c_flag : FlagRole .CarryFlagWithInvertedSubtractRole ,
9191 z_flag : FlagRole .ZeroFlagRole , v_flag : FlagRole .OverflowFlagRole , s_flag : FlagRole .NegativeSignFlagRole
9292 }
9393 flags_required_for_flag_condition = {
@@ -104,8 +104,8 @@ class M6502(Architecture):
104104 Mnemonic ("asl" ):lambda il , operand : il .store (1 , operand , il .shift_left (1 , il .load (1 , operand ), il .const (1 , 1 ), flags = FlagName ("czs" ))),
105105 Mnemonic ("asl@" ):lambda il , operand : il .set_reg (1 , a_reg , il .shift_left (1 , operand , il .const (1 , 1 ), flags = FlagName ("czs" ))),
106106 Mnemonic ("and" ):lambda il , operand : il .set_reg (1 , a_reg , il .and_expr (1 , il .reg (1 , a_reg ), operand , flags = FlagName ("zs" ))),
107- Mnemonic ("bcc" ):lambda il , operand : M6502 .cond_branch (il , il .flag_condition (LowLevelILFlagCondition .LLFC_UGE ), operand ),
108- Mnemonic ("bcs" ):lambda il , operand : M6502 .cond_branch (il , il .flag_condition (LowLevelILFlagCondition .LLFC_ULT ), operand ),
107+ Mnemonic ("bcc" ):lambda il , operand : M6502 .cond_branch (il , il .flag_condition (LowLevelILFlagCondition .LLFC_ULT ), operand ),
108+ Mnemonic ("bcs" ):lambda il , operand : M6502 .cond_branch (il , il .flag_condition (LowLevelILFlagCondition .LLFC_UGE ), operand ),
109109 Mnemonic ("beq" ):lambda il , operand : M6502 .cond_branch (il , il .flag_condition (LowLevelILFlagCondition .LLFC_E ), operand ),
110110 Mnemonic ("bit" ):lambda il , operand : il .and_expr (1 , il .reg (1 , a_reg ), operand , flags = FlagName ("czs" )),
111111 Mnemonic ("bmi" ):lambda il , operand : M6502 .cond_branch (il , il .flag_condition (LowLevelILFlagCondition .LLFC_NEG ), operand ),
@@ -528,15 +528,6 @@ def get_instruction_low_level_il(self, data: bytes, addr: int, il: LowLevelILFun
528528 il .append (i )
529529 return length
530530
531- def get_flag_write_low_level_il (self , op : LowLevelILOperation , size : int , write_type : Optional [FlagWriteTypeName ], flag : FlagType , operands : List [ILRegisterType ], il : LowLevelILFunction ) -> ExpressionIndex :
532- if flag == 'c' :
533- if (op == LowLevelILOperation .LLIL_SUB ) or (op == LowLevelILOperation .LLIL_SBB ):
534- # Subtraction carry flag is inverted from the commom implementation
535- return il .not_expr (0 , self .get_default_flag_write_low_level_il (op , size , FlagRole .CarryFlagRole , operands , il ))
536- # Other operations use a normal carry flag
537- return self .get_default_flag_write_low_level_il (op , size , FlagRole .CarryFlagRole , operands , il )
538- return Architecture .get_flag_write_low_level_il (self , op , size , write_type , flag , operands , il )
539-
540531 def is_never_branch_patch_available (self , data :bytes , addr :int ) -> bool :
541532 if (data [0 :1 ] == b"\x10 " ) or (data [0 :1 ] == b"\x30 " ) or (data [0 :1 ] == b"\x50 " ) or (data [0 :1 ] == b"\x70 " ) or (
542533 data [0 :1 ] == b"\x90 "
@@ -708,7 +699,7 @@ def perform_is_executable(self) -> bool:
708699 return True
709700
710701 def perform_get_address_size (self ) -> int :
711- return self . address_size
702+ return 2
712703
713704 def perform_get_entry_point (self ) -> int :
714705 return struct .unpack ("<H" , self .read (0xfffc , 2 ))[0 ]
0 commit comments