Чтение и печать строки в сборке руки

Я использую ARMSim и только начал изучать ассемблер, поэтому, пожалуйста, извините, если я выгляжу невежественным, но я пытаюсь прочитать строку из входного файла, а затем распечатать ее на экране вывода. Пока у меня есть:

.equ SWI_Open, 0x66 @open a file
.equ SWI_Close,0x68 @close a file
.equ SWI_PrChr,0x00 @ Write an ASCII char to Stdout
.equ SWI_PrStr, 0x69 @ Write a null-ending string 
.equ SWI_PrInt,0x6b @ Write an Integer
.equ SWI_RdInt,0x6c @ Read an Integer from a file
.equ Stdout, 1 @ Set output target to be Stdout
.equ SWI_Exit, 0x11 @ Stop execution
.equ SWI_RdStr, 0x6a @ Read string from file
.equ SWI_PrStg, 0x02 @print to Stdout
.global _start
.text
_start:

mov R0,#Stdout @print an initial message 
ldr R1, =Message1 @ load address of Message1 label
swi SWI_PrStr @ display message to Stdout


ldr R0,=InputName @ set Name for input file
mov R1,#0 @ mode is input
swi SWI_Open @ open file for input
bcs InFileError @ Check Carry-Bit (C): if= 1 then ERROR

RLoop:
ldr r0,=InputHandle @ load input file handle
ldr r0,[r0]
ldr R1,=CharArray
mov R2,#80
swi SWI_RdStr
bcs EofReached @ Check Carry-Bit (C): if= 1 then EOF reached

@ print the string to Stdout
mov R1,R0  @R1 = string to print
mov R0,#Stdout @ target is Stdout
swi SWI_PrStr
mov R0,#Stdout @ print new line
ldr R1, =NL
bal RLoop @ keep reading till end of file




EofReached:
mov R0, #Stdout @ print last message
ldr R1, =EndOfFileMsg
swi SWI_PrStr


  ldr R0, =InputHandle @ get address of file handle
  ldr R0, [R0] @ get value at address
  swi SWI_Close

Exit:
swi SWI_Exit @ stop executing 
InFileError:
  mov R0, #Stdout
  ldr R1, =FileOpenInpErrMsg
  swi SWI_PrStr 
  bal Exit @ give up, go to end


  .data
  .align
InputHandle: .skip 4
CharArray: .skip 80
InputName: .asciz "whatever.txt"
FileOpenInpErrMsg: .asciz "Failed to open input file \n"
EndOfFileMsg: .asciz "End of file reached\n"
ColonSpace: .asciz": "
NL: .asciz "\n_" @ new line 
Message1: .asciz "Reading String from udp.dat and printing out ASCII values. \n"
.end

До сих пор, когда я запускаю его, я могу нормально распечатать свое первоначальное сообщение. Проблема в том, что он не читает до конца файла, и я не получаю сообщение об окончании файла. Любые указатели были бы великолепны.

Ответы на вопрос(0)

Ваш ответ на вопрос