Hallo Gemeinschaft
Vielleicht kann mir Jemand helfen??
Das Problem ist ein kleines Kopierprogramm für Linux ARM (Pi 2B)
Es soll als Dauerschleife laufen und ist in Assembler mit Linux syscall read und write.
Der Fehler:
das Programm macht 510 Schleifen und hört dann mit dem kopieren auf!
Das Programm ist aber in der Programmliste (top) noch aktiv (aber nur mit ca 1,7 prozent)
Hier nun der Code:
@------------------------------------------------------------------------------
@ Test pi 2B Programm twG (testen)
@ gcc -o twG twG.s
@------------------------------------------------------------------------------
@ as -o twG.o twG.s -> main ersetzen mit _start sonst Fehlermeldung
@ ld -o twG twG.o
@------------------------------------------------------------------------------
.global main @ gcc -o
@ .global _start @ as -o -> ld -o
.section .data
@------------------------------------------------------------------------------
@------------------------------------------------------------------------------
fd_in:
.int 0x0
fd_out:
.int 0x0
@--------------------------
reserve:
.int 0x0
@----------parameter- sleep---------------------------------------------------
time_value:
.int 0 @ Sekunde
.int 2000000 @ 10mS /100mS 100000000
@------------------------------------
file_reada:
.asciz "/dev/shm/A/B640x480rgb0"
.align 2
@---write--------------------------
file_write2:
.asciz "/dev/shm/G/B640x480rgb0"
.align 2
@------------------------------------------------------------------------------
buffer_a:
.space 1024*901
@-Ende section .data---------------------------------------------------------
@-----------------------------------------------------------------------------
main: @ gcc
@ _start: @ as -> ld
mov r4 , #71 @ G
mov r5 , #72 @ H
@-----------------------------------
mov r3 , #65 @ A
mov r6 , #66 @ B
mov r8 , #1024 @ schleife
ldr r9 , =0x1 @ für Test
ldr r10 , =18 @ für Test 18d
@-----------------------------------------------------------------------------
loop_neu:
@--open the file for reading---hole Bilddavor (/C/B640x480rgb0)---------------
ldr r0 , =file_reada @
strb r3 , [r0,#9] @ pfad A oder B
mov r1 , #2 @ read
ldr r2 , =444 @ all
mov r7 , #5 @ syscall 5 open file
swi 0
ldr r1 , =fd_in
str r0 , [r1] @ Rückgabe-Wert
@-----------------------------------------------------------------------------
@-- read from file------------------------------------------------------------
@ ldr r1 , =fd_in
@ ldr r0 , [r1] @ deskriptor fd_in
ldr r1 , =buffer_a @ Zeiger -> Anfang der Daten
mov r2 , #1024*900
add r2 , #15 @ Anzahl Byte hier (900,0kiB 921615 Byte)
mov r7 , #3 @ syscall 3 -> read file
swi 0
@-----------------------------------------------------------------------------
@--close the file-------------------------------------------------------------
mov r7 , #6
@ ldr r1 , =fd_in
@ ldr r0 , [r1] @ deskriptor fd_in
swi 0
@------------------------------------------------------------------------------
str r9 , [r1, r10] @ r10 =ziel
add r9 , #1 @ kontrolle anzahl
@---lesen Ende-----------------------------------------------------------------
@-----create -----------------------------------------------------
ldr r0 , =file_write2
strb r4 , [r0,#9] @ pfad G H
ldr r1 , =444
mov r7 , #8 @ syscall 8 create
swi 0
ldr r1 , =fd_out
str r0 , [r1]
@-----write file---------------------------
mov r2 , #1024*900
add r2 , #15
ldr r1 , =buffer_a @ Quelle (Ergebnis)
@@ ldr r1 , =fd_out
@@ str r0 , [r1]
mov r7 , #4 @ syscall write 4
swi 0
@------------------------------------------
@@ ldr r1 , =fd_out
@@ str r0 , [r1]
mov r7 , #6 @ close
swi 0
@-----sleep sys 162 ----------------------------------------------------------
mov r7 , #162
ldr r0 , =time_value
mov r1 , #0
swi 0
@---------Test pfad read -----------------------------------------------------
add r3 , #1
cmp r3 , r6
ble pfadr_ok
sub r3 , #2
pfadr_ok:
@---------Test pfad write ----------------------------------------------------
add r4 , #1
cmp r4 , r5
ble pfad_ok
sub r4 , #2
pfad_ok:
@---------Durchlauf für Test--------------------------------------------------
@@ sub r8 , #1
@@ cmp r8 , #0
@@ bne loop_neu
b loop_neu @ max 0x01FE 510d -> warum ??
@-----------------------------------------------------------------------------
@--syscall exit 1 ------------------------------------------------------------
mov r7 , #1
mov r0 , #0
swi 0 @ Ende
Hilfen sind willkommen.
Gruß
Relbmessa