ARM 汇编语言 uART0 输入输出,我做错了什么. [英] ARM Assembly Language uART0 Input Output, What am I doing wrong.

查看:25
本文介绍了ARM 汇编语言 uART0 输入输出,我做错了什么.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写两 (2) 个 ARM 汇编语言子例程,称为 output_char 和 read_char.这些子程序将允许用户通过 UART 输入字符并在 PuTTy 中显示该字符.所有用户输入都应回显至显示器

Write two (2) ARM assembly language subroutines, called output_char and read_char. These subroutines will allow a user to enter a character and display the character in PuTTy via the UART. All user input should be echoed back to the display

我尝试编写代码,但没有奏效.

I tried writing the code but it did not work.

U0LSR EQU 0x14          
register EQU 0xE000C000


    STMFD SP!,{lr}  

read_character
    LDR r0, =0xE000C014
    LDRB r1, [r0]
    BIC r1, r1, #0xFFFFFFFE
    CMP r1, #0
    BEQ read_character
    LDR r6, =register
    LDR r2, [r6]



output_character
    LDR r0, =0xE000C014
    LDRB r1, [r0]
    BIC  r1, r1, #0xFFFFFFEF
    MOV r1, r1, LSR #1
    CMP r1, #0
    BEQ output_character
    LDR r6, =register
    STR r2, [r6]

    LDMFD sp!, {lr}
    BX lr

推荐答案

这个好像是相关的

http://csserver.evansville.edu/~blandfor/EE311/ARMLecture/UARTNotes.pdf

考虑到这些应该是两个独立的函数,上面的注释适用.此外,我将假设由于问题不涉及初始化 UART,否则它确实可以成功工作.STMFD/LDMFD/BX 三元组应与这两个功能相关联.另外,考虑到ARM过程调用标准

Considering these are supposed to be two separate functions, the previous comments above apply. Also, I will assume since the problem does not refer to initializing the UART, that it does work successfully otherwise. The STMFD/LDMFD/BX triplex should be associated with both functions. Also, considering the ARM procedure call standard

http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf

如果可能,您可能应该在您的程序中将自己限制在 R0-R3.如果您需要更多,您需要将它们添加到 STMFD/LDMFD 指令中,这样您就不会修改寄存器而不将它们返回到以前的状态.

you probably should limit yourself to R0-R3 in your procedures, if possible. If you need more, you need to add them to the STMFD/LDMFD instructions so you don't modify registers without returning them to their previous state.

问题陈述的写法,read_char函数需要调用write_char函数将输入的字符回显到屏幕上.您的答案中缺少这一点.看起来保存字符的寄存器与发送字符的寄存器相同,所以很好.否则 read_character 函数看起来没问题.

The way the problem statement is written, the read_char function needs to call the write_char function to echo the character typed back to the screen. That is missing in your answer. It looks like the register holding the character is the same as the register sending the character, so that's good. Otherwise the read_character function looks OK.

您的 write_character 函数看起来不太正确,但是您的 BIC 0xFFFF FFEF 看起来不正确.您想查看发送器空位,您应该使用 0xFFFF FFBF.作为一种风格,我建议将 AND 与您想要的位集一起使用,而不是 BIC 和相反.使它更容易看到.如果您在输出中没有看到任何内容,这很可能是问题所在,因为 LSR[4] 处的 BI(中断指示器)位可能永远不会变高,因此您的代码将永远循环.

Your write_character function doesn't look quite correct however, your BIC 0xFFFF FFEF doesn't look right. You want to be looking at the Transmitter Empty bit, you should be using 0xFFFF FFBF. As a point of style, I would recommend using AND with the bit set you want versus BIC and the inverse. Makes it easier to see. If you aren't seeing anything on your output, this is most likely the problem since the BI (break indicator) bit at LSR[4] is probably never going high, so your code is looping forever.

最后,问题陈述说使用 read_char 和 output_char 作为你的函数名,所以你需要将这些标签添加到 STMFD 指令中.你的 BEQ 很好,它需要循环回到从行状态寄存器读取的寄存器,所以它需要一个单独的目标标签.

Lastly, the problem statement says to use read_char and output_char as your function names, so you need to add those labels to the STMFD instructions for each. Your BEQ is fine, it needs to loop back to the register read from the line status register, so it needs a separate target label.

这篇关于ARM 汇编语言 uART0 输入输出,我做错了什么.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆