<commit_before>; firmware module for minimOS·16
; (c) 2018 <NAME>
; last modified 20181210-1111

; *** relocate 65816-based code and data ***
; interface TBD
; ex_pt <- code start_kernel


#ifdef	LOWRAM
.(
	.al: REP #$20		; save a couple bytes by going 16-bit again
	LDA #sysvars		; beginning of kernel space
	STA 		; set parameter
; must check THREE relocation tables: code (all), data (usually kernels & drivers only) and banks (for 65816)
; do NOT check headers here!!! use ZP parameters
	LDA ex_pt			; get code location...
	STA dynmem			; is the first 

	SEC
	SBC #256			; ...minus one page...
	STA rtab_pt			; ...and set as local header pointer
	LDY #REL_TAB		; offset for the first relocation table in headers
rl_tab:
		LDA (rtab_pt), Y	; get this table offset
		CLC
		ADC ex_pt			; get initial address
		STA dyntab			; use as local pointer
		PHY					; save for next table!
; relocate all references from current table
		LDY #0				; reset counter
; all set, let us convert the references
dyd_rel:
			LDA (dyntab), Y		; any more to convert?
				BEQ dd_end			; no, all done
			CLC
			ADC ex_pt			; yes, compute actual location of address
			STA tmptr			; store temporary pointer
			LDA (tmptr)			; this is the generic address to be converted
			EOR d_mask			; will be $4000 for data and 0 otherwise!
			CLC
			ADC dynmem			; the destination of these references
			STA (tmptr)			; address is corrected!
			INY					; go for next offset (assume 16-bit indexes)<commit_msg>RELOC needs unusual interface...<commit_after>; firmware module for minimOS·16
; (c) 2018 <NAME>
; last modified 20181210-1237

; *** relocate 65816-based code and data ***
; interface TBD
; ex_rlc <- code start address (24b) including bank at bnk_rl (+2)
; sv_rlc <- data start address, usually for kernel/drivers only (16b)
; rl_tab <- pointer to list of offsets (might point to ...

#ifdef	LOWRAM
.(
	.al: REP #$20		; save a couple bytes by going 16-bit again
; must check THREE relocation tables: code (all), data (usually kernels & drivers only) and banks (for 65816)
; do NOT check headers here!!! use ZP parameters
	LDA ex_pt			; get code location...
	STA dynmem			; is the first 

	SEC
	SBC #256			; ...minus one page...
	STA rtab_pt			; ...and set as local header pointer
	LDY #REL_TAB		; offset for the first relocation table in headers
rl_tab:
		LDA (rtab_pt), Y	; get this table offset
		CLC
		ADC ex_pt			; get initial address
		STA dyntab			; use as local pointer
		PHY					; save for next table!
; relocate all references from current table
		LDY #0				; reset counter
; all set, let us convert the references
dyd_rel:
			LDA (dyntab), Y		; any more to convert?
				BEQ dd_end			; no, all done
			CLC
			ADC ex_pt			; yes, compute actual location of address
			STA tmptr			; store temporary pointer
			LDA (tmptr)			; this is the generic address to be converted
			EOR d_mask			; will be $4000 for data and 0 otherwise!
			CLC
			ADC dynmem			; the destination of these references
			STA (tmptr)			; address is corrected!
			INY					; go for next offset (assume 16-bit indexes)
{'fraction_non_alphanumeric': 0.07732463295269168, 'fraction_numerical': 0.029690048939641108, 'mean_word_length': 3.0236220472440944, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4526991', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1002, 'n_words': 440}