从X指针读取数据并将其保存在数组中 - AVR Asm
我正在学习 Avr 组装。我正在编写一个读取 uart 字符串的项目,然后该字符串必须保存在数组中。然后必须将字符串发送回 uart TX 引脚。我正在对 ATMEGA8 微控制器进行编程。我不确定一切是否正确,并且可能有些代码不正确,因为我是 ASM avr 的初学者。
首先,我调用“gets”子例程来从 uart 引脚获取数据。 (我有来自 http://www.rjhcoding.com/avr-asm- 的代码uart.php)
gets:
in r17, UCSRA
sbrs r17, RXC
rjmp gets
in r16, UDR ; gets received character
cpi r16, $0D ; check if rcv'd char is CR (enter)
breq gets_end ; branch if CR
st X+,r16 ; store char in buffer
rjmp gets ; get another char
gets_end:
ldi r16, $00
st X+,r16
ret
但是我不明白这段代码,如何读取X缓冲区中的数据并将其放入新的数组中?我该如何制作和使用该数组?
I'm learning Avr Assembly. I'm writing a project that reads a uart string, then the string has to be saved in an array. Then the string has to be send back on the uart TX pin. I'm programming a ATMEGA8 microcontroller. I'm not sure everything is correct and probably some code will not be correct since I'm a starter in ASM avr.
first, I call the 'gets' subroutine to get the data from the uart pins.
(I have the code from http://www.rjhcoding.com/avr-asm-uart.php)
gets:
in r17, UCSRA
sbrs r17, RXC
rjmp gets
in r16, UDR ; gets received character
cpi r16, $0D ; check if rcv'd char is CR (enter)
breq gets_end ; branch if CR
st X+,r16 ; store char in buffer
rjmp gets ; get another char
gets_end:
ldi r16, $00
st X+,r16
ret
But what I don't get about this code, how do I read the data in the X buffer and put it in a new Array? And how do I make and use that array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论