file - 读取文本文件数据并将其显示到 LCD(ARM 语言)
问题描述
我需要从表示当前值的文本文件中读取整数数据并以交互方式测量它们,它们应该显示在 LCD 显示屏上,如果当前值大于阈值,则应该触发左侧 LED。最后,RMS 值和平均值应显示在 LCD 显示屏上。由于这只是模拟,我使用 ARMSim#(版本 1.9.1)来实现这一点,不幸的是我在 ARM 编程方面的技能有限。直到现在,我收集了一些导致我这样做的信息(它不起作用,我需要很多建议才能真正模拟这个)
.global _start
.text
_start:
@----- manipulate file for string reading and lcd writing-----
@----- input mode aperture for the file-----
loopbottonblack: @fire left or right led
swi 0x202 @ checks if one of the black buttons were pressed
cmp r0,#0x02 @left button pressed
beq ActOnLeftBlack @go label "ActOnLeftBlack"
cmp r0,#0x01 @right button pressed
beq ActOnRightBlack @go label "ActOnRightBlack"
bal loopbottonblack
ldr r0,=nomedoarquivo @ sets output file name
mov r1,#0 @ output mode
swi 0x66 @ open file for input
mov r6,r0
bcs erroarquivo @ mistake conditon
@inicio de ler strings
loop: @interative loop beginning
mov r0,r6
ldr r1,=manipulararquivo @ loads input file to manipulate
@ler string
ldr r1,=mystring
mov r3,r1
mov r2,#256
swi 0x6a @read a string in the file
bcs fim
@ldr r2,=emptystring @writes an empty string
@mov r0,#8 @ column number
@mov r1,#8 @ line number
@swi 0x204 @writes an empty string to LCD
@linha0
mov r2,r3
ldr r2,=mystring
mov r0,#0 @ column number
mov r1,#0 @ line number
swi 0x204 @writes a read string to the file
@linha1
mov r2,r3
ldr r2,=mystring
mov r0,#0 @ column number
mov r1,#1 @ line number
swi 0x204 @writes a read string to the file
@linha2
mov r2,r3
ldr r2,=mystring
mov r0,#0 @ column number
mov r1,#2 @ line number
swi 0x204 @writes a lcd string to the file
@linha3
ldr r4,=0
ldr r5,=300000
loopbottonblack2: @fire left of right led
swi 0x202 @ checks if one of the black buttons were pressed
cmp r0,#0x02 @left button pressed
beq ActOnLeftBlack @go label "ActOnLeftBlack"
cmp r0,#0x01 @right button pressed
beq ActOnRightBlack @go label "ActOnRightBlack"
bal looptime
ActOnLeftBlack: @fires left LED
mov r0,#0x02
swi 0x201 @shows left led (on)
bal looptime @go label "loopbottonblack" and do not end the program
ActOnRightBlack: @fires the right led
mov r0,#0x01
swi 0x201 @shows the right led (on)
bal looptime @go label "fimdoprograma" and ends the program
looptime: @introduces a delay to see all read lines of the file
add r4,r4,#1
cmp r4,r5 @compares r4 and r5
ble looptime @if r4 has a smaller value than 100000 goes back to looptime
bal loop @end of interactive loop
@end of reading strings
erroarquivo:
mov r0, #1
ldr r1, =menserroarquivo
swi 0x69
bal fim @ goes to the end of the program
fim:
@ == closes the file ============
ldr r0, =manipulararquivo @ takes the adress of manipulated file
ldr r0, [r0] @ take values in the adress
swi 0x68
swi 0x11 @stops executing
.data
.align
mystring: .asciz "" @set a variable with a string
nomedoarquivo: .asciz "file.txt"
menserroarquivo: .asciz "nao habil para abrir o arquivo de saida\n"
manipulararquivo: .word 0
emptystring: .asciz " " @set variable with an empty string
@----- manipulating files to write string end-----
.end
解决方案
推荐阅读
- qt - 在 mime 数据函数中制作树结构
- jquery - 使用 jQuery 限制复选框(一次一个类别和一个子类别)
- ios - 使用 swift 中的按钮操作控制 Web 视图
- python-3.x - 如何“PUT”json数据包含汉字?
- javascript - 运行位于 fastclick 中的测试会导致 Jest 崩溃
- javascript - 谷歌表格脚本不起作用?(用于更改其他选项卡中值的数组)
- javascript - 通过数字或字符串为 Date() 赋值有什么区别?
- javascript - 如何使用 v-for 循环使用 Vue.js 遍历列
- javascript - 如何获得对象acc的最大值形式。到不同的-不同的键
- javascript - 500 内部服务器错误,nodejs resetpassword 函数中的请求超时