Skip to content
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

Feature request: inline assembly clobbering #1996

Open
fgsoftware1 opened this issue Feb 25, 2025 · 7 comments
Open

Feature request: inline assembly clobbering #1996

fgsoftware1 opened this issue Feb 25, 2025 · 7 comments
Milestone

Comments

@fgsoftware1
Copy link

No description provided.

@lerno
Copy link
Collaborator

lerno commented Feb 25, 2025

Do you have any suggested syntax?

@fgsoftware1
Copy link
Author

Do you have any suggested syntax?

not at all but here goes some:

uint cr0;

asm
{
   "movl %0, $cr0 "
}(eax);

another thing i though was explicit input/output operands maybe using attributes style?

@lerno
Copy link
Collaborator

lerno commented Feb 26, 2025

Umm.. did you test the asm syntax yet?

@fgsoftware1
Copy link
Author

Umm.. did you test the asm syntax yet?

i haven't figure out how to do blocks and i think processing asm blocks at the end is a bad idea in some cases like:

u32 cr0;
    asm volatile ("mov %%cr0, %0" : "=r" (cr0));
    cr0 |= 1 << 31;
    asm volatile ("mov %0, %%cr0" : : "r" (cr0)); 

@fgsoftware1
Copy link
Author

Umm.. did you test the asm syntax yet?

i haven't figure out how to do blocks and i think processing asm blocks at the end is a bad idea in some cases like:

u32 cr0;
asm volatile ("mov %%cr0, %0" : "=r" (cr0));
cr0 |= 1 << 31;
asm volatile ("mov %0, %%cr0" : : "r" (cr0));

this is an example in C

@lerno
Copy link
Collaborator

lerno commented Mar 10, 2025

The way asm works in C3 is like:

int x;
asm
{
  in $eax, 3;
  in $ax, $dx;
  incb $al;
  incl [&x];
  ...
}

A clobber would perhaps look like

asm
{
  @invalidate($eax);
  @invalidate(mem);
}

@fgsoftware1
Copy link
Author

The way asm works in C3 is like:

int x;
asm
{
in $eax, 3;
in $ax, $dx;
incb $al;
incl [&x];
...
}

A clobber would perhaps look like

asm
{
@invalidate($eax);
@invalidate(mem);
}

yeah that looks nice

@lerno lerno added this to the Asm fixes milestone Mar 10, 2025
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

No branches or pull requests

2 participants