@@ -18,11 +18,8 @@ pub unsafe fn set_cs(sel: SegmentSelector) {
1818 #[ cfg( feature = "inline_asm" ) ]
1919 #[ inline( always) ]
2020 unsafe fn inner ( sel : SegmentSelector ) {
21- llvm_asm ! ( "pushq $0; \
22- leaq 1f(%rip), %rax; \
23- pushq %rax; \
24- lretq; \
25- 1:" :: "ri" ( u64 :: from( sel. 0 ) ) : "rax" "memory" ) ;
21+ // FIXME - Use intel syntax
22+ asm ! ( "pushq {}; leaq 1f(%rip), %rax; pushq %rax; lretq; 1:" , in( reg) u64 :: from( sel. 0 ) , out( "rax" ) _, options( att_syntax) ) ;
2623 }
2724
2825 #[ cfg( not( feature = "inline_asm" ) ) ]
@@ -43,7 +40,7 @@ pub unsafe fn set_cs(sel: SegmentSelector) {
4340#[ inline]
4441pub unsafe fn load_ss ( sel : SegmentSelector ) {
4542 #[ cfg( feature = "inline_asm" ) ]
46- llvm_asm ! ( "movw $0, %ss " :: "r" ( sel. 0 ) : "memory" ) ;
43+ asm ! ( "mov ss, {0:x}" , in ( reg ) sel. 0 , options ( nostack ) ) ;
4744
4845 #[ cfg( not( feature = "inline_asm" ) ) ]
4946 crate :: asm:: x86_64_asm_load_ss ( sel. 0 ) ;
@@ -58,7 +55,7 @@ pub unsafe fn load_ss(sel: SegmentSelector) {
5855#[ inline]
5956pub unsafe fn load_ds ( sel : SegmentSelector ) {
6057 #[ cfg( feature = "inline_asm" ) ]
61- llvm_asm ! ( "movw $0, %ds " :: "r" ( sel. 0 ) : "memory" ) ;
58+ asm ! ( "mov ds, {0:x}" , in ( reg ) sel. 0 , options ( nostack ) ) ;
6259
6360 #[ cfg( not( feature = "inline_asm" ) ) ]
6461 crate :: asm:: x86_64_asm_load_ds ( sel. 0 ) ;
@@ -73,7 +70,7 @@ pub unsafe fn load_ds(sel: SegmentSelector) {
7370#[ inline]
7471pub unsafe fn load_es ( sel : SegmentSelector ) {
7572 #[ cfg( feature = "inline_asm" ) ]
76- llvm_asm ! ( "movw $0, %es " :: "r" ( sel. 0 ) : "memory" ) ;
73+ asm ! ( "mov es, {0:x}" , in ( reg ) sel. 0 , options ( nostack ) ) ;
7774
7875 #[ cfg( not( feature = "inline_asm" ) ) ]
7976 crate :: asm:: x86_64_asm_load_es ( sel. 0 ) ;
@@ -88,7 +85,7 @@ pub unsafe fn load_es(sel: SegmentSelector) {
8885#[ inline]
8986pub unsafe fn load_fs ( sel : SegmentSelector ) {
9087 #[ cfg( feature = "inline_asm" ) ]
91- llvm_asm ! ( "movw $0, %fs " :: "r" ( sel. 0 ) : "memory" ) ;
88+ asm ! ( "mov fs, {0:x}" , in ( reg ) sel. 0 , options ( nostack ) ) ;
9289
9390 #[ cfg( not( feature = "inline_asm" ) ) ]
9491 crate :: asm:: x86_64_asm_load_fs ( sel. 0 ) ;
@@ -103,7 +100,7 @@ pub unsafe fn load_fs(sel: SegmentSelector) {
103100#[ inline]
104101pub unsafe fn load_gs ( sel : SegmentSelector ) {
105102 #[ cfg( feature = "inline_asm" ) ]
106- llvm_asm ! ( "movw $0, %gs " :: "r" ( sel. 0 ) : "memory" ) ;
103+ asm ! ( "mov gs, {0:x}" , in ( reg ) sel. 0 , options ( nostack ) ) ;
107104
108105 #[ cfg( not( feature = "inline_asm" ) ) ]
109106 crate :: asm:: x86_64_asm_load_gs ( sel. 0 ) ;
@@ -118,7 +115,7 @@ pub unsafe fn load_gs(sel: SegmentSelector) {
118115#[ inline]
119116pub unsafe fn swap_gs ( ) {
120117 #[ cfg( feature = "inline_asm" ) ]
121- llvm_asm ! ( "swapgs" :: : "memory" : "volatile" ) ;
118+ asm ! ( "swapgs" , options ( nostack ) ) ;
122119
123120 #[ cfg( not( feature = "inline_asm" ) ) ]
124121 crate :: asm:: x86_64_asm_swapgs ( ) ;
@@ -130,7 +127,9 @@ pub fn cs() -> SegmentSelector {
130127 #[ cfg( feature = "inline_asm" ) ]
131128 {
132129 let segment: u16 ;
133- unsafe { llvm_asm ! ( "mov %cs, $0" : "=r" ( segment) ) } ;
130+ unsafe {
131+ asm ! ( "mov {0:x}, cs" , out( reg) segment, options( nostack, nomem) )
132+ } ;
134133 SegmentSelector ( segment)
135134 }
136135
0 commit comments