Skip to contentSkip to conversation

x86: simplify ljmp to 32-bit code

PATCH New Masahiro Yamada 2 participants 3 messages Dec 3, 2019 – Dec 8, 2019 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: simplify ljmp to 32-bit code

You can directly specify the label as the operand for ljmp.

This commit saves 4-byte code.

---

 arch/x86/cpu/start16.S | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/cpu/start16.S +1 -3
index bcabd76741ef..7bad9f3e4d87 100644
@@ -44,10 +44,8 @@ data32 cs	lgdt	gdt_ptr
 ff:
 
 	/* Finally restore BIST and jump to the 32-bit initialization code */
-	movw	$code32start, %ax
-	movw	%ax, %bp
 	movl	%ecx, %eax
-data32 cs	ljmp	*(%bp)
+data32 cs	ljmp	code32start
 
 	/* 48-bit far pointer */
 code32start:
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 x86: simplify ljmp to 32-bit code

Hi Masahiro,

Quoted 16 lines · Masahiro Yamada

You can directly specify the label as the operand for ljmp.

This commit saves 4-byte code.

---

 arch/x86/cpu/start16.S | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/cpu/start16.S +0 -0
index bcabd76741ef..7bad9f3e4d87 100644

arch/x86/cpu/start16.S data32 cs lgdt gdt_ptr · line 48

Quoted 8 lines
arch/x86/cpu/start16.S +1 -3
@@ -44,10 +44,8 @@ data32 cs    lgdt    gdt_ptr
 ff:
 
        /* Finally restore BIST and jump to the 32-bit initialization code */
-       movw    $code32start, %ax
-       movw    %ax, %bp
        movl    %ecx, %eax
-data32 cs      ljmp    *(%bp)
+data32 cs      ljmp    code32start

There should be a * before code32start, otherwise gas reportes:

arch/x86/cpu/start16.S: Assembler messages:
arch/x86/cpu/start16.S:48: Warning: indirect ljmp without `*'

arch/x86/cpu/start16.S data32 cs lgdt gdt_ptr

Quoted 4 lines
arch/x86/cpu/start16.S +0 -1
        /* 48-bit far pointer */
 code32start:
--

Regards,
Bin

#2 lore raw

PATCH 1/1 x86: simplify ljmp to 32-bit code

Quoted 31 lines · Bin Meng

Hi Masahiro,

Quoted 16 lines · Masahiro Yamada

You can directly specify the label as the operand for ljmp.

This commit saves 4-byte code.

---

 arch/x86/cpu/start16.S | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/cpu/start16.S +0 -0
index bcabd76741ef..7bad9f3e4d87 100644

arch/x86/cpu/start16.S data32 cs lgdt gdt_ptr · line 48

Quoted 8 lines
arch/x86/cpu/start16.S +1 -3
@@ -44,10 +44,8 @@ data32 cs    lgdt    gdt_ptr
 ff:
 
        /* Finally restore BIST and jump to the 32-bit initialization code */
-       movw    $code32start, %ax
-       movw    %ax, %bp
        movl    %ecx, %eax
-data32 cs      ljmp    *(%bp)
+data32 cs      ljmp    code32start

There should be a * before code32start, otherwise gas reportes:

Quoted 2 lines

arch/x86/cpu/start16.S: Assembler messages:
arch/x86/cpu/start16.S:48: Warning: indirect ljmp without `*'

fixed the warning by adding * before code32start

Quoted 8 lines

arch/x86/cpu/start16.S data32 cs lgdt gdt_ptr

Quoted 5 lines
arch/x86/cpu/start16.S +0 -1
        /* 48-bit far pointer */
 code32start:
--

and applied to u-boot-x86, thanks!