Skip to content

Fix the inline assembly examples #24842

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

Merged
merged 3 commits into from
Apr 30, 2015
Merged

Fix the inline assembly examples #24842

merged 3 commits into from
Apr 30, 2015

Conversation

strega-nil
Copy link
Contributor

They now use the currently working syntax.

Also, I added two examples.

They now use the currently working syntax.
@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@strega-nil
Copy link
Contributor Author

r? @steveklabnik

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 26, 2015

📌 Commit a70b2ed has been approved by steveklabnik

@steveklabnik
Copy link
Member

Thank you!

@bors
Copy link
Collaborator

bors commented Apr 27, 2015

⌛ Testing commit a70b2ed with merge c13dd9d...

@@ -100,6 +100,21 @@ fn main() {
}
```

If you would like to use real operands in this position, however,
you are required to put curly braces `{}` around the register that
you want, and you are required to put the specific size of the
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe this is true, e.g. #24799 (comment) .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is, I have tried it both ways.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, well it's definitely not always required. E.g. to add to the example above, this also works (the not indicates that the correct register size is being used and it's not just, say, defaulting to eax in some way: the output is fffffffffffffffd):

#![feature(asm)]

fn main() {
    let mut test: u64;
    unsafe {
        asm!("mov $$2, %rax
              not %rax" 
             : "={ax}"(test));
    }
    println!("{:x}", test);
}

What's the other way in your example? (al -> ax?)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, or maybe just {a}? It seems that {ax} always works (I see no difference in the asm between al and ax), but just a presumably means something different to LLVM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That must be it. Just {a} doesn't work right now.

@bors
Copy link
Collaborator

bors commented Apr 27, 2015

💔 Test failed - auto-linux-64-nopt-t

@pnkfelix
Copy link
Member

@bors r=steveklabnik 766c1bc

bors added a commit that referenced this pull request Apr 30, 2015
They now use the currently working syntax.

Also, I added two examples.
@bors
Copy link
Collaborator

bors commented Apr 30, 2015

⌛ Testing commit 766c1bc with merge 42bfeec...

@bors bors merged commit 766c1bc into rust-lang:master Apr 30, 2015
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.

8 participants