Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #741 from shigoel/collaborate
Fixed a bug in the implementation of opcode 0x90, plus merging in some edits from Alessandro Coglio.
- Loading branch information
Showing
7 changed files
with
203 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
books/projects/x86isa/tools/execution/examples/nop-sequence/xchg.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Shilpi Goel | ||
|
||
// gcc xchg.c -o xchg.o | ||
|
||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
// See pre-defined macros supported by your GCC using: | ||
// gcc -dM -E - < /dev/null | ||
|
||
uint64_t xchg (void) { | ||
|
||
uint64_t n,m; | ||
__asm__ volatile | ||
( | ||
"mov $0x1, %%rax\n\t" | ||
"mov $0xFFFFFFFF, %%r8\n\t" | ||
"xchg %%ax, %%r8w\n\t" | ||
"mov %%r8, %1\n\t" | ||
: "=a"(n),"=g"(m) // output list | ||
|
||
: // input list | ||
|
||
: "cc", "memory"); | ||
|
||
printf("\nValue in rax: 0x%llx\n", n); | ||
printf("\nValue in r8: 0x%llx\n", m); | ||
|
||
return (0); | ||
} | ||
|
||
int main () { | ||
|
||
xchg(); | ||
|
||
return 0; | ||
|
||
} |
Oops, something went wrong.