请问用汇编程序VisUAL如何做到十六进制数逆序
假设有一个十六进制数0xABCDEF01,要用简易汇编程序让它逆序变成0x10FEDCBA,请问要怎么实现呢? #include <stdio.h>#include <stdint.h>
uint32_t reverse(uint32_t data) {
uint32_t result;
__asm__ ("1:\n\t"
"movl%%edx, %%ebx\n\t"
"shrl$4, %%edx\n\t"
"andl$0x0f, %%ebx\n\t"
"shll$4, %%eax\n\t"
"orl %%ebx, %%eax\n\t"
"loop1b":"=a"(result):"a"(0), "d"(data), "c"(8));
return result;
}
int main(void) {
uint32_t data = 0xABCDEF01;
printf("0x%.8X: 0x%.8X\n", data, reverse(data));
return 0;
}
页:
[1]