<commit_before><commit_msg>type in <NAME>'s divide-by-10 code<commit_after>; divide-by-10 algorithm by <NAME>

; input = value.w
; output = mod10 (.w?)
; string = message

divide:
; intitialise reminder to zero
	STZ mod10
	STZ mod10+1
	CLC

	LDX #16
divloop:
; rotate quotient and reminder
		ROL value
		ROL value+1
		ROL mod10
		ROL mod10+1

; AY = dividend-divisor
		SEC
		LDA mod10
		SBC #10
		TAY					; save low byte
		LDA mod10+1
		SBC #0
		BCC ignore_result	; branch if dividend < divisor
			STY mod10
			STA mod10+1
ignore_result:
		DEX
		BNE divloop
	ROL value				; shift in the last bit of quotient
	ROL value+1

lda mod10
	CLC
	ADC #'0'
	; print...
	JSR push_char

; if value != 0, continue
	LDA value
	ORA value+1
	BNE divide
; *** end, print string ***

; *** routines ***
; add char in A to beginning of string
push_char:
	PHA						; first char onto stack
	LDY #0
char_loop:
		LDX message, Y
		PLA
		STA message, Y			; pull char and add it to the string
		INY
		TXA
		PHA						; push char from string onto stack
		BNE char_loop
	PLA
	STA message, Y				; pull NULL from stack and terminate string
	RTS
{'fraction_non_alphanumeric': 0.07726864330637916, 'fraction_numerical': 0.03504043126684636, 'mean_word_length': 2.8546712802768166, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4344321', 'n_tokens_mistral': 494, 'n_tokens_neox': 424, 'n_words': 158}