Skip to contentSkip to conversation

Reduce boot header size with 1 byte

PATCH In review [email protected] 3 participants 3 messages Sep 27, 2018 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Reduce boot header size with 1 byte

From: Alexander F. Rødseth <[email protected]>

Only ah needs to be set to 0 before calling interrupt 0x16 for waiting for a keypress.

This patch changes the line that uses xor so that it only zeroes "ah" instead of "ax". This saves a byte.

---
 arch/x86/boot/header.S | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
arch/x86/boot/header.S +6 -5
index 850b8762e889..905cb96f43d4 100644
@@ -71,14 +71,15 @@ msg_loop:
 	jmp	msg_loop
 
 bs_die:
-	# Allow the user to press a key, then reboot
-	xorw	%ax, %ax
+	# Allow the user to press a key
+	xorb	%ah, %ah
 	int	$0x16
+
+	# Boostrap by reading sector 1, head 0, track 0 from drive
 	int	$0x19
 
-	# int 0x19 should never return.  In case it does anyway,
-	# invoke the BIOS reset code...
-	ljmp	$0xf000,$0xfff0
+	# If boostrap somehow did not work, invoke the BIOS reset code
+	ljmp	$0xf000, $0xfff0
 
 #ifdef CONFIG_EFI_STUB
 	.org	0x3c
Signature · 1 line
2.19.0
#1 lore raw
Quoted 9 lines · On 9/27/18 6:41 AM, [email protected] wrote:

From: Alexander F. Rødseth <[email protected]>

Only ah needs to be set to 0 before calling interrupt 0x16 for waiting for a keypress.

This patch changes the line that uses xor so that it only zeroes "ah" instead of "ax". This saves a byte.

Hi,

You should Cc: the X86 maintainers on this patch.
Otherwise it will just be lost in the ether.

thanks.

Quoted 30 lines
---
 arch/x86/boot/header.S | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
arch/x86/boot/header.S +6 -5
index 850b8762e889..905cb96f43d4 100644
@@ -71,14 +71,15 @@ msg_loop:
 	jmp	msg_loop
 
 bs_die:
-	# Allow the user to press a key, then reboot
-	xorw	%ax, %ax
+	# Allow the user to press a key
+	xorb	%ah, %ah
 	int	$0x16
+
+	# Boostrap by reading sector 1, head 0, track 0 from drive
 	int	$0x19
 
-	# int 0x19 should never return.  In case it does anyway,
-	# invoke the BIOS reset code...
-	ljmp	$0xf000,$0xfff0
+	# If boostrap somehow did not work, invoke the BIOS reset code
+	ljmp	$0xf000, $0xfff0
 
 #ifdef CONFIG_EFI_STUB
 	.org	0x3c
Signature · 1 line
~Randy
#2 lore raw
In reply to [email protected]
Quoted 19 lines · On Thu, Sep 27, 2018 at 9:42 AM <[email protected]> wrote:

From: Alexander F. Rødseth <[email protected]>

Only ah needs to be set to 0 before calling interrupt 0x16 for waiting for a keypress.

This patch changes the line that uses xor so that it only zeroes "ah" instead of "ax". This saves a byte.

---
 arch/x86/boot/header.S | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
arch/x86/boot/header.S +0 -0
index 850b8762e889..905cb96f43d4 100644

arch/x86/boot/header.S msg_loop: · line 75

Quoted 7 lines
arch/x86/boot/header.S +2 -2
@@ -71,14 +71,15 @@ msg_loop:
        jmp     msg_loop
 
 bs_die:
-       # Allow the user to press a key, then reboot
-       xorw    %ax, %ax
+       # Allow the user to press a key
+       xorb    %ah, %ah

Because this is code running in 16-bit real mode, xorw does not need a 16-bit prefix and only uses 2 bytes. You save nothing by using xorb.

--
Brian Gerst