Improve assembly quality + AT&T syntax.

This commit is contained in:
Tobias Decking 2023-02-22 00:07:41 +01:00 committed by GitHub
parent 44d34e87fa
commit b53c1ae17a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,24 +179,25 @@ pub unsafe fn c_string_length(s: *const core::ffi::c_char) -> usize {
asm!(
// search for a zero byte
"xor al, al",
"xor %eax, %eax",
// unbounded memory region
"xor rcx, rcx",
"not rcx",
"xor %ecx, %ecx",
"not %rcx",
// forward direction
"cld",
// (already set thanks to abi)
//"cld",
// perform search
"repne scasb",
"repne scasb (%rdi), %al",
// extract length
"not rcx",
"dec rcx",
"not %rcx",
"dec %rcx",
inout("rdi") s => _,
out("rcx") n,
options(nostack),
options(att_syntax, nostack),
);
n