<commit_before>#
# Copyright (c) 1999 <NAME>
# All rights reserved.
#
# Redistribution and use in source and binary forms are freely
# permitted provided that the above copyright notice and this
# paragraph and the following disclaimer are duplicated in all
# such forms.
#
# This software is provided "AS IS" and without any express or
# implied warranties, including, without limitation, the implied
# warranties of merchantability and fitness for a particular
# purpose.
#

#	$Id: $

# Master boot record

		.set LOAD,0x7c00		# Load address
		.set EXEC,0x600 		# Execution address
		.set PT_OFF,0x1be		# Partition table
		.set MAGIC,0xaa55		# Magic: bootable

		.set NDRIVE,0x8 		# Drives to support

		.globl start			# Entry point

start:		cld				# String ops inc
		xorl %eax,%eax			# Zero
		movl %eax,%es			# Address
		movl %eax,%ds			#  data
		cli				# Disable interrupts
		movl %eax,%ss			# Set up
		movwir(LOAD,_sp)		#  stack
		sti				# Enable interrupts
		movwir(main-EXEC+LOAD,_si)	# Source
		movwir(main,_di)		# Destination
		movwir(0x200-(main-start),_cx)	# Word count
		rep				# Relocate
		movsb				#  code
		jmpnwi(main-LOAD+EXEC)		# To relocated code

main:		xorl %esi,%esi			# No active found
		movwir(partbl,_bx)		# Partition table
		movb $0x4,%cl			# Entries
main.1: 	cmpbr0(_ch,_bx_)		# Null entry?
		je main.2			# Yes
		jg err_pt			# If bit 7 unset
		testl %esi,%esi 		# Active found?
		jnz err_pt			# Yes
		movl %ebx,%esi			# Keep place
main.2: 	addb $0x10,%bl			# Till
		loop main.1			#  done
		testl %esi,%esi 		# Active found?
		jnz main.3			# Yes
		int $0x18			# BIOS: Diskless boot

main.3: 	cmpb $0x80,%dl			# Drive valid?
		jb main.4			# No
		cmpb $0x80+NDRIVE,%dl		# Within range?
		jb main.5			# Yes
main.4: 	movb0r(_si_,_dl)		# Load drive
main.5: 	movb1r(0x1,_si_,_dh)		# Load head
		movw1r(0x2,_si_,_cx)		# Load cylinder:sector
		movwir(LOAD,_bx)		# Transfer buffer
		movwir(0x201,_ax)		# BIOS: Read from
		int $0x13			#  disk
		jc err_rd			# If error
		cmpwi2(MAGIC,0x1fe,_bx_)	# Bootable?
		jne err_os			# No
		jmp *%ebx			# Invoke bootstrap

err_pt: 	movwir(msg_pt,_si)		# "Invalid partition
		jmp putstr			#  table"

err_rd: 	movwir(msg_rd,_si)		# "Error loading
		jmp putstr			#  operating system"

err_os: 	movwir(msg_os,_si)		# "Missing operating
		jmp putstr			#  system"

putstr.0:	movwir(0x7,_bx) 		# Page:attribute
		movb $0xe,%ah			# BIOS: Display
		int $0x10			#  character
putstr: 	lodsb				# Get character
		testb %al,%al			# End of string?
		jnz putstr.0			# No
putstr.1:	jmp putstr.1			# Await reset

msg_pt: 	.asciz "Invalid partition table"
msg_rd: 	.asciz "Error loading operating system"
msg_os: 	.asciz "Missing operating system"

		.org PT_OFF

partbl: 	.fill 0x10,0x4,0x0		# Partition table
		.word MAGIC			# Magic number
<commit_msg>Correct and clarify some comments.<commit_after>#
# Copyright (c) 1999 <NAME>
# All rights reserved.
#
# Redistribution and use in source and binary forms are freely
# permitted provided that the above copyright notice and this
# paragraph and the following disclaimer are duplicated in all
# such forms.
#
# This software is provided "AS IS" and without any express or
# implied warranties, including, without limitation, the implied
# warranties of merchantability and fitness for a particular
# purpose.
#

#	$Id: mbr.s,v 1.1.1.1 1999/05/24 22:36:24 rnordier Exp $

# Master boot record

		.set LOAD,0x7c00		# Load address
		.set EXEC,0x600 		# Execution address
		.set PT_OFF,0x1be		# Partition table
		.set MAGIC,0xaa55		# Magic: bootable

		.set NDRIVE,0x8 		# Drives to support

		.globl start			# Entry point

start:		cld				# String ops inc
		xorl %eax,%eax			# Zero
		movl %eax,%es			# Address
		movl %eax,%ds			#  data
		cli				# Disable interrupts
		movl %eax,%ss			# Set up
		movwir(LOAD,_sp)		#  stack
		sti				# Enable interrupts
		movwir(main-EXEC+LOAD,_si)	# Source
		movwir(main,_di)		# Destination
		movwir(0x200-(main-start),_cx)	# Byte count
		rep				# Relocate
		movsb				#  code
		jmpnwi(main-LOAD+EXEC)		# To relocated code

main:		xorl %esi,%esi			# No active partition
		movwir(partbl,_bx)		# Partition table
		movb $0x4,%cl			# Number of entries
main.1: 	cmpbr0(_ch,_bx_)		# Null entry?
		je main.2			# Yes
		jg err_pt			# If 0x1..0x7f
		testl %esi,%esi 		# Active already found?
		jnz err_pt			# Yes
		movl %ebx,%esi			# Point to active
main.2: 	addb $0x10,%bl			# Till
		loop main.1			#  done
		testl %esi,%esi 		# Active found?
		jnz main.3			# Yes
		int $0x18			# BIOS: Diskless boot

main.3: 	cmpb $0x80,%dl			# Drive valid?
		jb main.4			# No
		cmpb $0x80+NDRIVE,%dl		# Within range?
		jb main.5			# Yes
main.4: 	movb0r(_si_,_dl)		# Load drive
main.5: 	movb1r(0x1,_si_,_dh)		# Load head
		movw1r(0x2,_si_,_cx)		# Load cylinder:sector
		movwir(LOAD,_bx)		# Transfer buffer
		movwir(0x201,_ax)		# BIOS: Read from
		int $0x13			#  disk
		jc err_rd			# If error
		cmpwi2(MAGIC,0x1fe,_bx_)	# Bootable?
		jne err_os			# No
		jmp *%ebx			# Invoke bootstrap

err_pt: 	movwir(msg_pt,_si)		# "Invalid partition
		jmp putstr			#  table"

err_rd: 	movwir(msg_rd,_si)		# "Error loading
		jmp putstr			#  operating system"

err_os: 	movwir(msg_os,_si)		# "Missing operating
		jmp putstr			#  system"

putstr.0:	movwir(0x7,_bx) 		# Page:attribute
		movb $0xe,%ah			# BIOS: Display
		int $0x10			#  character
putstr: 	lodsb				# Get character
		testb %al,%al			# End of string?
		jnz putstr.0			# No
putstr.1:	jmp putstr.1			# Await reset

msg_pt: 	.asciz "Invalid partition table"
msg_rd: 	.asciz "Error loading operating system"
msg_os: 	.asciz "Missing operating system"

		.org PT_OFF

partbl: 	.fill 0x10,0x4,0x0		# Partition table
		.word MAGIC			# Magic number

{'fraction_non_alphanumeric': 0.1011453744493392, 'fraction_numerical': 0.03295154185022026, 'mean_word_length': 3.143065693430657, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '7114795', 'n_tokens_mistral': 2732, 'n_tokens_neox': 2379, 'n_words': 642}