Skip to content

Commit 54b4e3f

Browse files
committed
Move set_cs to Intel Syntax
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 69542a0 commit 54b4e3f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/instructions/segmentation.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::structures::gdt::SegmentSelector;
55
/// Reload code segment register.
66
///
77
/// Note this is special since we can not directly move
8-
/// to %cs. Instead we push the new segment selector
9-
/// and return value on the stack and use lretq
8+
/// to cs. Instead we push the new segment selector
9+
/// and return value on the stack and use retf
1010
/// to reload cs and continue at 1:.
1111
///
1212
/// ## Safety
@@ -18,8 +18,15 @@ pub unsafe fn set_cs(sel: SegmentSelector) {
1818
#[cfg(feature = "inline_asm")]
1919
#[inline(always)]
2020
unsafe fn inner(sel: SegmentSelector) {
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));
21+
asm!(
22+
"push {sel}",
23+
"lea {tmp}, [1f + rip]",
24+
"push {tmp}",
25+
"retfq",
26+
"1:",
27+
sel = in(reg) u64::from(sel.0),
28+
tmp = lateout(reg) _,
29+
);
2330
}
2431

2532
#[cfg(not(feature = "inline_asm"))]

0 commit comments

Comments
 (0)