Skip to content

Remove remaining traces of AT&T assembly syntax #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TDecking
Copy link
Contributor

@TDecking TDecking commented May 8, 2025

The current minimum LLVM version seems to be 18, way larger than required for resolving this FIXME.

core::arch::asm!(
"repe movsb (%rsi), (%rdi)",
asm!(
"repe movsb [rdi], rsi",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original asm both rsi and rdi are dereferenced, here it’s only rdi. Is this still equivalent for some reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is. I fixed this.

core::arch::asm!(
"repe movsb (%rsi), (%rdi)",
asm!(
"repe movsb [rdi], [rsi]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"repe movsb [rdi], [rsi]",
"rep movsb [rdi], [rsi]",

The repe mnemonic is for "repeat while equal" and only makes sense for the string comparison operations
https://www.felixcloutier.com/x86/rep:repe:repz:repne:repnz
(but the encoding is the same so I guess assemblers don't care)

core::arch::asm!(
"repe stosb %al, (%rdi)",
asm!(
"repe stosb [rdi], al",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"repe stosb [rdi], al",
"rep stosb [rdi], al",

Comment on lines 84 to +85
// We modify flags, but we restore it afterwards
options(att_syntax, nostack, preserves_flags)
options(nostack, preserves_flags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely shouldn't have preserves_flags. Flags are modified by each of add,sub,test. The comment refers to how std/cld are used to set/clear the direction flag, but that's separate since it must be cleared before exiting the inline assembly.

Actually, what is the point of the test instruction here? It only affects flags, and none of the subsequent instructions depend on any flags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants