Чтение данных текстового файла и отображение их на ЖК-дисплее (язык ARM) - PullRequest
0 голосов
/ 19 ноября 2018

Мне нужно прочитать целочисленные данные из текстового файла, представляющего текущие значения, и измерить их в интерактивном режиме, они должны отображаться на ЖК-дисплее, и если текущее значение превышает пороговое значение, левый светодиод должен гореть. В конце значение RMS и среднее значение должны быть представлены на ЖК-дисплее. Поскольку это только симуляция, я использую 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
...