arm 汇编语言 汉诺塔
求问如何使用arm汇编语言完成汉诺塔程序?用的软件是visUAL,很多指令都没办法用{:10_266:} 谢谢啦,给个思路也行 直接反编译gcc生成的可执行文件#include <stdio.h>
size_t count = 0;
void hanoi(size_t n, char a, char b, char c) {
if(n == 1) {
printf("%2lu: %c -> %c\n", ++count, a, c);
} else{
hanoi(n - 1, a, c, b);
printf("%2lu: %c -> %c\n", ++count, a, c);
hanoi(n - 1, b, a, c);
}
}
int main(void) {
hanoi(4, 'a', 'b', 'c');
return 0;
}
size_t count = 0;
void hanoi(size_t n, char a, char b, char c) {
794: a9be7bfd stp x29, x30, !
798: 910003fd mov x29, sp
79c: f9000fe0 str x0,
7a0: 39005fe1 strb w1,
7a4: 39005be2 strb w2,
7a8: 390057e3 strb w3,
if(n == 1) {
7ac: f9400fe0 ldr x0,
7b0: f100041f cmp x0, #0x1
7b4: 54000281 b.ne 804 <hanoi+0x70>// b.any
printf("%2lu: %c -> %c\n", ++count, a, c);
7b8: b0000080 adrp x0, 11000 <__cxa_finalize@GLIBC_2.17>
7bc: 91010000 add x0, x0, #0x40
7c0: f9400000 ldr x0,
7c4: 91000401 add x1, x0, #0x1
7c8: b0000080 adrp x0, 11000 <__cxa_finalize@GLIBC_2.17>
7cc: 91010000 add x0, x0, #0x40
7d0: f9000001 str x1,
7d4: b0000080 adrp x0, 11000 <__cxa_finalize@GLIBC_2.17>
7d8: 91010000 add x0, x0, #0x40
7dc: f9400000 ldr x0,
7e0: 39405fe1 ldrb w1,
7e4: 394057e2 ldrb w2,
7e8: 2a0203e3 mov w3, w2
7ec: 2a0103e2 mov w2, w1
7f0: aa0003e1 mov x1, x0
7f4: 90000000 adrp x0, 0 <__abi_tag-0x278>
7f8: 91254000 add x0, x0, #0x950
7fc: 97ffff95 bl 650 <printf@plt>
} else{
hanoi(n - 1, a, c, b);
printf("%2lu: %c -> %c\n", ++count, a, c);
hanoi(n - 1, b, a, c);
}
}
800: 1400001f b 87c <hanoi+0xe8>
hanoi(n - 1, a, c, b);
804: f9400fe0 ldr x0,
808: d1000400 sub x0, x0, #0x1
80c: 39405be3 ldrb w3,
810: 394057e2 ldrb w2,
814: 39405fe1 ldrb w1,
818: 97ffffdf bl 794 <hanoi>
printf("%2lu: %c -> %c\n", ++count, a, c);
81c: b0000080 adrp x0, 11000 <__cxa_finalize@GLIBC_2.17>
820: 91010000 add x0, x0, #0x40
824: f9400000 ldr x0,
828: 91000401 add x1, x0, #0x1
82c: b0000080 adrp x0, 11000 <__cxa_finalize@GLIBC_2.17>
830: 91010000 add x0, x0, #0x40
834: f9000001 str x1,
838: b0000080 adrp x0, 11000 <__cxa_finalize@GLIBC_2.17>
83c: 91010000 add x0, x0, #0x40
840: f9400000 ldr x0,
844: 39405fe1 ldrb w1,
848: 394057e2 ldrb w2,
84c: 2a0203e3 mov w3, w2
850: 2a0103e2 mov w2, w1
854: aa0003e1 mov x1, x0
858: 90000000 adrp x0, 0 <__abi_tag-0x278>
85c: 91254000 add x0, x0, #0x950
860: 97ffff7c bl 650 <printf@plt>
hanoi(n - 1, b, a, c);
864: f9400fe0 ldr x0,
868: d1000400 sub x0, x0, #0x1
86c: 394057e3 ldrb w3,
870: 39405fe2 ldrb w2,
874: 39405be1 ldrb w1,
878: 97ffffc7 bl 794 <hanoi>
}
87c: d503201f nop
880: a8c27bfd ldp x29, x30, , #32
884: d65f03c0 ret
0000000000000888 <main>:
int main(void) {
888: a9bf7bfd stp x29, x30, !
88c: 910003fd mov x29, sp
hanoi(4, 'a', 'b', 'c');
890: 52800c63 mov w3, #0x63 // #99
894: 52800c42 mov w2, #0x62 // #98
898: 52800c21 mov w1, #0x61 // #97
89c: d2800080 mov x0, #0x4 // #4
8a0: 97ffffbd bl 794 <hanoi>
return 0;
8a4: 52800000 mov w0, #0x0 // #0
}
8a8: a8c17bfd ldp x29, x30, , #16
8ac: d65f03c0 ret
页:
[1]