Skip to content

Instantly share code, notes, and snippets.

@kohnakagawa
Created December 15, 2021 04:53
Show Gist options
  • Save kohnakagawa/7e3dc12730e1e306283775433c03498e to your computer and use it in GitHub Desktop.
Save kohnakagawa/7e3dc12730e1e306283775433c03498e to your computer and use it in GitHub Desktop.
ARM64 の ubfx 命令の挙動をテストするためのプログラム
#include <stdio.h>
#include <stdint.h>
__attribute__((noinline))
uint64_t ubfx(uint64_t src) {
uint64_t ret = 0x5555555555555555;
asm volatile ("ubfx %0, %1, #4, #24"
: "=r"(ret)
: "r"(src));
return ret;
}
int main(){
uint64_t src = 0x823456789ABCDEF0;
printf("%lx\n", ubfx(src));
}
@kohnakagawa
Copy link
Author

実行結果

nanoha:~/src$ ./a.out
abcdef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment