@@ -18,11 +18,8 @@ pub unsafe fn set_cs(sel: SegmentSelector) {
18
18
#[ cfg( feature = "inline_asm" ) ]
19
19
#[ inline( always) ]
20
20
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) ) ;
26
23
}
27
24
28
25
#[ cfg( not( feature = "inline_asm" ) ) ]
@@ -43,7 +40,7 @@ pub unsafe fn set_cs(sel: SegmentSelector) {
43
40
#[ inline]
44
41
pub unsafe fn load_ss ( sel : SegmentSelector ) {
45
42
#[ 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 ) ) ;
47
44
48
45
#[ cfg( not( feature = "inline_asm" ) ) ]
49
46
crate :: asm:: x86_64_asm_load_ss ( sel. 0 ) ;
@@ -58,7 +55,7 @@ pub unsafe fn load_ss(sel: SegmentSelector) {
58
55
#[ inline]
59
56
pub unsafe fn load_ds ( sel : SegmentSelector ) {
60
57
#[ 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 ) ) ;
62
59
63
60
#[ cfg( not( feature = "inline_asm" ) ) ]
64
61
crate :: asm:: x86_64_asm_load_ds ( sel. 0 ) ;
@@ -73,7 +70,7 @@ pub unsafe fn load_ds(sel: SegmentSelector) {
73
70
#[ inline]
74
71
pub unsafe fn load_es ( sel : SegmentSelector ) {
75
72
#[ 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 ) ) ;
77
74
78
75
#[ cfg( not( feature = "inline_asm" ) ) ]
79
76
crate :: asm:: x86_64_asm_load_es ( sel. 0 ) ;
@@ -88,7 +85,7 @@ pub unsafe fn load_es(sel: SegmentSelector) {
88
85
#[ inline]
89
86
pub unsafe fn load_fs ( sel : SegmentSelector ) {
90
87
#[ 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 ) ) ;
92
89
93
90
#[ cfg( not( feature = "inline_asm" ) ) ]
94
91
crate :: asm:: x86_64_asm_load_fs ( sel. 0 ) ;
@@ -103,7 +100,7 @@ pub unsafe fn load_fs(sel: SegmentSelector) {
103
100
#[ inline]
104
101
pub unsafe fn load_gs ( sel : SegmentSelector ) {
105
102
#[ 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 ) ) ;
107
104
108
105
#[ cfg( not( feature = "inline_asm" ) ) ]
109
106
crate :: asm:: x86_64_asm_load_gs ( sel. 0 ) ;
@@ -118,7 +115,7 @@ pub unsafe fn load_gs(sel: SegmentSelector) {
118
115
#[ inline]
119
116
pub unsafe fn swap_gs ( ) {
120
117
#[ cfg( feature = "inline_asm" ) ]
121
- llvm_asm ! ( "swapgs" :: : "memory" : "volatile" ) ;
118
+ asm ! ( "swapgs" , options ( nostack ) ) ;
122
119
123
120
#[ cfg( not( feature = "inline_asm" ) ) ]
124
121
crate :: asm:: x86_64_asm_swapgs ( ) ;
@@ -130,7 +127,9 @@ pub fn cs() -> SegmentSelector {
130
127
#[ cfg( feature = "inline_asm" ) ]
131
128
{
132
129
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
+ } ;
134
133
SegmentSelector ( segment)
135
134
}
136
135
0 commit comments