⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bootlace.inc

📁 grub4dos-0.4.4-2008- 08-src.zip
💻 INC
📖 第 1 页 / 共 5 页
字号:
/* *  bootlace.inc -- code shared by 16-bit DOS and 32-bit Linux *  Copyright (C) 2005,2006,2007  Tinybit(tinybit@tom.com) * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */	.file	"bootlace.inc"#ifdef __DOS_16#undef ABS#define ABS(x) (x - _start + 0x100)#undef iBX#define iBX	%bx#undef iSI#define iSI	%si#undef iDI#define iDI	%di#undef iDX#define iDX	%dx#undef LEAL#define LEAL	ADDR32 leal#undef MOVZWL#define MOVZWL	ADDR32 movzwl#undef MOVL#define MOVL	ADDR32 movl#undef MOVW#define MOVW	ADDR32 movw#undef CMPL#define CMPL	ADDR32 cmpl#undef CMPW#define CMPW	ADDR32 cmpw#undef SUBL#define SUBL	ADDR32 subl#undef SBBL#define SBBL	ADDR32 sbbl#undef NEGL#define NEGL	ADDR32 negl#undef NOTL#define NOTL	ADDR32 notl#undef ADCL#define ADCL	ADDR32 adcl#undef ADDL#define ADDL	ADDR32 addl#undef DIVL#define DIVL	ADDR32 divl	. = _start + 0x34		// dos entry point invalid_dos_exec #if 0	movl	$ABS(msg_invalid_dos), %ecx	call	8f	movw	$0x4c01, %ax		// EXIT - TERMINATE WITH RETURN CODE 1	int	$0x21			// call DOS#else	jmp	1f#endif	//////////////////////////////////////////////////////////////////////		. = _start + 0x47		// dos entry point1:	/* dos entry point */	movl	$0x81, %esi	movl	%esi, %edi	movl	$0x7f, %ecx	movb	$0x0d, %al	/* CR */	cld	repnz scasb	decl	%edi		/* points to CR */	std	movb	$0, %al	stosb	movl	%edi, %esi	xorl	%ecx, %ecx	pushl	%ecx		/* 0 is the end of argv */	xorl	%edx, %edx	/* find spaces */3:	cmpl	$0x81, %edi	jb	3f	lodsb	cmpb	$0x20, %al	je	1f	cmpb	$0x09, %al	jne	2f1:	testl	%edx, %edx	jz	1f	notl	%edx	incl	%edi	pushl	%edi		/* argv */	decl	%edi1:	movb	$0, %al	stosb	jmp	3b2:	testl	%edx, %edx	jnz	1f	incl	%ecx	notl	%edx1:	stosb	jmp	3b3:	testl	%edx, %edx	jz	1f	incl	%edi	pushl	%edi1:	pushl	%esi		/* dummy for program name */	incl	%ecx	pushl	%ecx		/* argc */	cld#else#undef ABS#define ABS(x) (x)#undef iBX#define iBX	%ebx#undef iSI#define iSI	%esi#undef iDI#define iDI	%edi#undef iDX#define iDX	%edx#undef LEAL#define LEAL	leal#undef MOVZWL#define MOVZWL	movzwl#undef MOVL#define MOVL	movl#undef MOVW#define MOVW	movw#undef CMPL#define CMPL	cmpl#undef CMPW#define CMPW	cmpw#undef SUBL#define SUBL	subl#undef SBBL#define SBBL	sbbl#undef NEGL#define NEGL	negl#undef NOTL#define NOTL	notl#undef ADCL#define ADCL	adcl#undef ADDL#define ADDL	addl#undef DIVL#define DIVL	divl#endif	popl	%ecx		# argc	/* argc must be > 1 */	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$1, %ecx	movl	$ABS(msg_no_args), %ecx	jbe	4f	/* error */	/* Note: ECX does not hold the argc now. */	xorl	%eax, %eax		# EAX will point to file name	//movl	%ebx, ABS(filename)	# save 0 to filename	popl	%ecx		# discard argv[0], the program name1:	popl	%ecx		# argv	movl	%ecx, %ebx	test 	%ecx, %ecx	jz	1f		# end of arguments	/* check if it is an option */	cmpb	$0x2D, (iBX)	# "-"	jz	2f	/* it is a filename */	testl	%eax, %eax	# filename already specified?	//cmpl	$0, ABS(filename)	jz	3f	/* error: only one file should be specified. */	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		movl	$ABS(msg_too_many_files), %ecx	jmp	4f	/* error */3:	/* not yet, this is the first filename */	movl	%ecx, %eax		# save ECX to EAX	//movl	%ecx, ABS(filename)	# save ECX to filename	jmp	1b			# continue2:	/* it is an option */	/* check --no-backup-mbr */	movl	$16, %ecx	movl	$ABS(option_no_backup_mbr), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$1, ABS(backup_mbr)	movl	$ABS(msg_option_backup_mbr), %ecx	jnz	4f	/* error */	movl	$0, ABS(backup_mbr)	jmp	1b3:	/* check --force-backup-mbr */	movl	$19, %ecx	movl	$ABS(option_force_backup_mbr), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$1, ABS(backup_mbr)	movl	$ABS(msg_option_backup_mbr), %ecx	jnz	4f	/* error */	movl	$2, ABS(backup_mbr)	jmp	1b3:	/* check --mbr-enable-floppy */	movl	$20, %ecx	movl	$ABS(option_mbr_enable_floppy), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(mbr_floppy)	movl	$ABS(msg_option_mbr_floppy), %ecx	jnz	4f	/* error */	movl	$2, ABS(mbr_floppy)	jmp	1b3:	/* check --mbr-disable-floppy */	movl	$21, %ecx	movl	$ABS(option_mbr_disable_floppy), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(mbr_floppy)	movl	$ABS(msg_option_mbr_floppy), %ecx	jnz	4f	/* error */	movl	$1, ABS(mbr_floppy)	jmp	1b3:	/* check --mbr-enable-osbr */	movl	$18, %ecx	movl	$ABS(option_mbr_enable_osbr), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(mbr_osbr)	movl	$ABS(msg_option_mbr_osbr), %ecx	jnz	4f	/* error */	movl	$2, ABS(mbr_osbr)	jmp	1b3:	/* check --mbr-disable-osbr */	movl	$19, %ecx	movl	$ABS(option_mbr_disable_osbr), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(mbr_osbr)	movl	$ABS(msg_option_mbr_osbr), %ecx	jnz	4f	/* error */	movl	$1, ABS(mbr_osbr)	jmp	1b3:	/* check --duce */	movl	$7, %ecx	movl	$ABS(option_duce), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(duce)	movl	$ABS(msg_option_duce), %ecx	jnz	4f	/* error */	movl	$1, ABS(duce)	jmp	1b3:	/* check --boot-prevmbr-first */	movl	$21, %ecx	movl	$ABS(option_boot_prevmbr_first), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(boot_prevmbr)	movl	$ABS(msg_option_boot_prevmbr), %ecx	jnz	4f	/* error */	movl	$1, ABS(boot_prevmbr)	jmp	1b3:	/* check --boot-prevmbr-last */	movl	$20, %ecx	movl	$ABS(option_boot_prevmbr_last), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0, ABS(boot_prevmbr)	movl	$ABS(msg_option_boot_prevmbr), %ecx	jnz	4f	/* error */	movl	$2, ABS(boot_prevmbr)	jmp	1b3:	/* check --preferred-drive= */	movl	$18, %ecx	movl	$ABS(option_preferred_drive), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xff, ABS(preferred_drive)	movl	$ABS(msg_option_preferred_drive), %ecx	jnz	4f	/* error */	movl	$0xfe, %ebx	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	movl	%edi, ABS(preferred_drive)	jmp	1b3:	/* check --preferred-partition= */	movl	$22, %ecx	movl	$ABS(option_preferred_partition), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xff, ABS(preferred_partition)	movl	$ABS(msg_option_preferred_partition), %ecx	jnz	4f	/* error */	movl	$0xfe, %ebx	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	movl	%edi, ABS(preferred_partition)	jmp	1b3:	/* check --time-out= */	movl	$11, %ecx	movl	$ABS(option_time_out), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xffffff05, ABS(time_out)	movl	$ABS(msg_option_time_out), %ecx	jnz	4f	/* error */	movl	$0xff, %ebx	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	movl	%edi, ABS(time_out)	jmp	1b3:	/* check --hot-key= */	movl	$10, %ecx	movl	$ABS(option_hot_key), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xffff3920, ABS(hot_key)	movl	$ABS(msg_option_hot_key), %ecx	jnz	4f	/* error */	movl	$0xffff, %ebx	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	movl	%edi, ABS(hot_key)	jmp	1b3:	/* check --install-partition= */	movl	$20, %ecx	movl	$ABS(option_install_partition), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xffffffff, ABS(install_partition)	movl	$ABS(msg_option_install_partition), %ecx	jnz	4f	/* error */	movl	$0xffff, %ebx	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	movl	%edi, ABS(install_partition)	jmp	1b3:	/* check --sectors-per-track= */	movl	$20, %ecx	movl	$ABS(option_sectors_per_track), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xffffff3f, ABS(sectors_per_track)	movl	$ABS(msg_option_sectors_per_track), %ecx	jnz	4f	/* error */	movl	$0x3f, %ebx	# maximum is 63	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	cmpl	$0, %edi	je	4f	/* error */	movl	%edi, ABS(sectors_per_track)	jmp	1b3:	/* check --heads= */	movl	$8, %ecx	movl	$ABS(option_heads), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xffff00ff, ABS(heads)	movl	$ABS(msg_option_heads), %ecx	jnz	4f	/* error */	movl	$0x100, %ebx	# maximum is 256	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	cmpl	$0, %edi	je	4f	/* error */	movl	%edi, ABS(heads)	jmp	1b3:	/* check --start-sector= */	movl	$15, %ecx	movl	$ABS(option_start_sector), %esi	movl	%ebx, %edi	cld	repz cmpsb	jnz	3f	xorl	%ebx, %ebx	# invalid file descriptor for CLOSE below		cmpl	$0xffffffff, ABS(start_sector)	movl	$ABS(msg_option_start_sector), %ecx	jnz	4f	/* error */	movl	$0xfffffffe, %ebx	call	7f	/* parse_number */	movl	%ebx, %edi	# save EBX to EDI	movl	$0, %ebx	# invalid file descriptor for CLOSE below	movl	$ABS(msg_invalid_number), %ecx	jc	4f	/* error */	movl	%edi, ABS(start_sector)	jmp	1b3:	/* check --total-sectors= */	movl	$16, %ecx	movl	$ABS(option_total_sectors), %esi	movl	%ebx, %edi	cld	repz cmpsb

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -