我希望在ASM汇编代码中创建前16个斐波那契数字,并将它们存储在我的微处理器中,从位置0x300开始 我有
ldi r16, 0 #load register 16 with 0
ldi r17, 1
add r17, r16
mov r18, r17
sts 0x300, r18 #store first number in 0x300
mov r16, r17
mov r17, r18
rjmp loop
我的问题是我如何在16个号码之后停止&如何在0x301,0x301 ... 0x315中存储每个数字 我不清楚在mov r17之后要放什么,r18将0x300增加到0x301并启用计数
答案 0 :(得分:1)
16岁后@stop 尝试添加一个计数器
ldi r20,16 #loop counter
start:
...#your loop body
dec r20
brne start
@how将每个数字存储在0x301中, 阅读“间接寻址” 有一个X间接寄存器:
X,Y,Z:间接地址寄存器(X = R27:R26,Y = R29:R28和Z = R31:R30) 所以你应该把你的地址放在X中,并使用“st X +,Rr”
clr r26 #this is lower 00 from 0x300
ldi r27,3 #this is higher 3 from 0x300 and here you've got X set to 0x300
...#some of your code
st x+,r18 #where r18 got data to be stroed in memory. x will be increased automaticly