sha0coder/libscemu

bsf not setting f_cf to 0

Closed this issue · 3 comments

121 0x144ed424a: bsf   ax,r12w
	diff_flags: rip = 144ed424a 
	diff_reg: rip = 144ed424a rax ffffffffffedaca5 -> ffffffffffed0002; 
	rax: 0xffffffffffed0002 rbx: 0x0 rcx: 0x140000000 rdx: 0x100000000 rsi: 0x14f418 rdi: 0x144e47256 rbp: 0x144ed4239 rsp: 0x14f290
	r8: 0x0 r9: 0x0 r10: 0x7ffe0384 r11: 0x1bb09de77 r12: 0x1448a76a4 r13: 0x0 r14: 0x140000000 r15: 0x0
	r8d: 0x0 r9d: 0x0 r10d: 0x7ffe0384 r11d: 0xbb09de77 r12d: 0x448a76a4 r13d: 0x0 r14d: 0x40000000 r15d: 0x0
	r8l: 0x0 r9l: 0x0 r10l: 0x84 r11l: 0x77 r12l: 0xa4 r13l: 0x0 r14l: 0x0 r15l: 0x0
	r8w: 0x0 r9w: 0x0 r10w: 0x384 r11w: 0xde77 r12w: 0x76a4 r13w: 0x0 r14w: 0x0 r15w: 0x0
	cf: true pf: true af: false zf: false sf: false tf: false if: false df: false of: false nt: false
122 0x144ed424f: adc   r10,rbx
	diff_flags: rip = 144ed424f f_cf 1 -> 0; f_pf 1 -> 0; 
	diff_reg: rip = 144ed424f r10 7ffe0384 -> 7ffe0385; 
	rax: 0xffffffffffed0002 rbx: 0x0 rcx: 0x140000000 rdx: 0x100000000 rsi: 0x14f418 rdi: 0x144e47256 rbp: 0x144ed4239 rsp: 0x14f290
	r8: 0x0 r9: 0x0 r10: 0x7ffe0385 r11: 0x1bb09de77 r12: 0x1448a76a4 r13: 0x0 r14: 0x140000000 r15: 0x0
	r8d: 0x0 r9d: 0x0 r10d: 0x7ffe0385 r11d: 0xbb09de77 r12d: 0x448a76a4 r13d: 0x0 r14d: 0x40000000 r15d: 0x0
	r8l: 0x0 r9l: 0x0 r10l: 0x85 r11l: 0x77 r12l: 0xa4 r13l: 0x0 r14l: 0x0 r15l: 0x0
	r8w: 0x0 r9w: 0x0 r10w: 0x385 r11w: 0xde77 r12w: 0x76a4 r13w: 0x0 r14w: 0x0 r15w: 0x0
	cf: false pf: false af: false zf: false sf: false tf: false if: false df: false of: false nt: false

this is valid, setting it to 1. next instruction is bsf. should set it to 0.

diff_flags: rip = 144ed4249 f_cf 0 -> 1;

120 0x144ed4249: cmc
	diff_flags: rip = 144ed4249 f_cf 0 -> 1;
	diff_reg: rip = 144ed4249
	rax: 0xffffffffffedaca5 rbx: 0x0 rcx: 0x140000000 rdx: 0x100000000 rsi: 0x14f418 rdi: 0x144e47256 rbp: 0x144ed4239 rsp: 0x14f290
	r8: 0x0 r9: 0x0 r10: 0x7ffe0384 r11: 0x1bb09de77 r12: 0x1448a76a4 r13: 0x0 r14: 0x140000000 r15: 0x0
	r8d: 0x0 r9d: 0x0 r10d: 0x7ffe0384 r11d: 0xbb09de77 r12d: 0x448a76a4 r13d: 0x0 r14d: 0x40000000 r15d: 0x0
	r8l: 0x0 r9l: 0x0 r10l: 0x84 r11l: 0x77 r12l: 0xa4 r13l: 0x0 r14l: 0x0 r15l: 0x0
	r8w: 0x0 r9w: 0x0 r10w: 0x384 r11w: 0xde77 r12w: 0x76a4 r13w: 0x0 r14w: 0x0 r15w: 0x0
	cf: true pf: true af: false zf: false sf: false tf: false if: false df: false of: false nt: false

The CF, OF, SF, AF, and PF flags are undefined on BSF :)

fixed with inline workaround