访问KEIL中的DCB和DCW内存类型
我是汇编的新手,目前正在研究一个项目,以尝试使用ARM Assembly语言和C ++开发单词云。我正在开发以下功能:
getfreq访问称为DCW内存类型的表中的数字。限制之一是该函数必须在汇编中写入,然后由我的C ++程序拨打,
这是当前如何查看函数的方式:
GetFreq ADR r3, table ;load the table into memory
LDRB R2, [R3, #4] ;access a byte
CMP r2, #0 ;compare it to 0 to see if we are at the end of the table
LDRB R0, [R2] ;return output
BNE GetFreq ;go to the next
BX LR
这是存储数据的方式:
ALIGN ; use this directive to start the entire data block on a word boundary
table DCB "pears",0 ; strings must be null-terminated
DCW 8 ; frequency is a 16-bit half-word
DCB "apples",0
DCW 16
DCB "pie",0
DCW 30
DCB "beans",0
DCW 12
DCB 0 ; A zero byte here indicates table termination
如果我删除cmp r2,#0 < /代码>我返回了值8,但是我似乎无法弄清楚如何访问其他数字。我也一直在努力寻找有关访问这种记忆的任何其他文档,因此我非常感谢所有帮助。
I'm a newbie at assembly and I am currently working on a project to try and develop a word cloud using ARM Assembly language and C++. I am developing the following function:
GetFreq to access a number in a table declared as a DCW memory type. One of the restraints is the function must be written in assembly and then called by my C++ program
This is currently how the function is looking:
GetFreq ADR r3, table ;load the table into memory
LDRB R2, [R3, #4] ;access a byte
CMP r2, #0 ;compare it to 0 to see if we are at the end of the table
LDRB R0, [R2] ;return output
BNE GetFreq ;go to the next
BX LR
This is how the data is being stored:
ALIGN ; use this directive to start the entire data block on a word boundary
table DCB "pears",0 ; strings must be null-terminated
DCW 8 ; frequency is a 16-bit half-word
DCB "apples",0
DCW 16
DCB "pie",0
DCW 30
DCB "beans",0
DCW 12
DCB 0 ; A zero byte here indicates table termination
If I remove the CMP r2, #0
I get the value 8 returned, however I can not seem to work out how to access the other numbers. I've also been struggling to find any other documentation on accessing memory like this, so I would really appreciate any and all help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论