作者DonaldTrunnp (The US President)
看板Programming
标题Re: [问题] 1-9位数不重复印出来 (ARM Assembly)
时间Sat Dec 17 04:59:59 2016
01 .cpu cortex-m4 23 chk_nodup:
02 .syntax unified 24 push {r1, lr}
25 mov r0, r1
03 .text 26 mov r3, #0
04 .global main 27 chk_loop:
05 main: 28 cmp r0, #0
06 mov r0, #0 29 it eq
07 loop: 30 popeq {r1, pc}
08 bl next_perm
31 mov r2, #10
09 // show register 0 32 udiv r1, r0, r2
33 mul r1, r2
10 b loop 34 sub r1, r0, r1
35 udiv r0, r2
11 next_perm:
12 push {lr} 36 mov r2, #1
13 next_loop: 37 lsl r2, r1
14 add r0, #1 38 mov r1, r2
15 mov r1, r0 39 and r2, r3
16 bl chk_nodup
17 eor r0, r1 40 cmp r2, #0
18 eor r1, r0 41 itt ne
19 eor r0, r1 42 movne r0, #1
43 popne {r1, pc}
20 cmp r1, #1
21 beq next_loop 44 orr r3, r1
22 pop {pc} 45 b chk_loop
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.113.66.155
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Programming/M.1481922002.A.243.html
※ 编辑: DonaldTrunnp (140.113.66.155), 12/17/2016 13:05:30
2F:推 lc85301: 开始出现asm 了 (._.) 140.112.25.105 12/17 13:42
3F:推 shadowjohn: 可以写一下怎compiler吗 36.233.136.119 12/17 18:12
$ arm-none-eabi-as -mcpu=cortex-m4 -o code.o code.s
$ arm-none-eabi-gcc -mcpu=cortex-m4 --specs=nosys.specs -o code.elf code.o
或是直接使用板子提供的开发环境会方便许多
如果想要在普通 PC 上执行的话,建议转写成 x86 的 inline assembly
※ 编辑: DonaldTrunnp (140.113.66.155), 12/17/2016 19:32:19
4F:推 chuegou: 下一篇pic 36.230.110.124 12/18 17:34
5F:→ DonaldTrunnp: 也可以挑战 Verilog 或 VHDL 140.113.66.155 12/18 23:34
6F:推 lc85301: 普通pc 可以用qemu 来跑 140.112.16.185 12/20 11:26