Skip to content

Commit 0a0fa0b

Browse files
authored
Improve assembly quality + AT&T syntax.
1 parent 1fdf932 commit 0a0fa0b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/mem/x86_64.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,25 @@ pub unsafe fn c_string_length(s: *const core::ffi::c_char) -> usize {
179179

180180
asm!(
181181
// search for a zero byte
182-
"xor al, al",
182+
"xor %eax, %eax",
183183

184184
// unbounded memory region
185-
"xor rcx, rcx",
186-
"not rcx",
185+
"xor %ecx, %ecx",
186+
"not %rcx",
187187

188188
// forward direction
189-
"cld",
189+
// (already set thanks to abi)
190+
//"cld",
190191

191192
// perform search
192-
"repne scasb",
193+
"repne scasb (%rdi), %al",
193194

194195
// extract length
195-
"not rcx",
196-
"dec rcx",
196+
"not %rcx",
197+
"dec %rcx",
197198
inout("rdi") s => _,
198199
out("rcx") n,
199-
options(nostack),
200+
options(att_syntax, nostack),
200201
);
201202

202203
n

0 commit comments

Comments
 (0)