<commit_before>package core

/* Perform LSL instruction, updating condition codes */
func LSL(regs *Registers, value uint32, shift_n uint8, S bool) uint32 {
	var result uint32
	var carry_out bool

	if shift_n == 0 {
		result, carry_out = value, regs.Apsr.C
	} else {
		result, carry_out = LSL_C(value, shift_n)
	}

	if S {
		regs.Apsr.N = (result & 0x80000000) != 0
		regs.Apsr.Z = (result) == 0
		regs.Apsr.C = carry_out
	}

	return result
}

/* Left shift value by a positive amount */
func LSL_C(value uint32, amount uint8) (uint32, bool) {
	extended := uint64(value)

	extended = extended << amount

	result := uint32(extended & 0xffffffff)
	carry_out := (extended & 0x100000000) != 0

	return result, carry_out
}<commit_msg>Make shift operations generic<commit_after>package core

type ShiftFunc func (uint32, uint8) (uint32, bool)

/* Perform shift operation, updating condition codes */
func ShiftOp(regs *Registers, value uint32, shift_n uint8, S bool, do_shift ShiftFunc) uint32 {
	var result uint32
	var carry_out bool

	if shift_n == 0 {
		result, carry_out = value, regs.Apsr.C
	} else {
		result, carry_out = do_shift(value, shift_n)
	}

	if S {
		regs.Apsr.N = (result & 0x80000000) != 0
		regs.Apsr.Z = (result) == 0
		regs.Apsr.C = carry_out
	}

	return result
}

/* Perform LSL instruction, updating condition codes */
func LSL(regs *Registers, value uint32, shift_n uint8, S bool) uint32 {
	return ShiftOp(regs, value, shift_n, S, LSL_C)
}

/* Left shift value by a positive amount */
func LSL_C(value uint32, amount uint8) (uint32, bool) {
	extended := uint64(value)

	extended = extended << amount

	result := uint32(extended & 0xffffffff)
	carry_out := (extended & 0x100000000) != 0

	return result, carry_out
}
{'fraction_non_alphanumeric': 0.11200923787528869, 'fraction_numerical': 0.05196304849884527, 'mean_word_length': 4.008670520231214, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3185445', 'n_tokens_mistral': 717, 'n_tokens_neox': 619, 'n_words': 190}