armsim中的Rot13不能读取多行

armsim中的Rot13不能读取多行,arm,rot13,Arm,Rot13,我正在用armsim写一个rot13,除了它不会读下一行之外,一切都正常 .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

我正在用armsim写一个rot13,除了它不会读下一行之外,一切都正常

.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 SWI_RdStr, 0x6a @ Read string from file
.equ Stdout, 1 @ Set output target to be Stdout
.equ SWI_Exit, 0x11 @ Stop execution
.global _start
.text
_start:

ldr r0,=InFileName @ set Name for input file
mov r1,#0 @ mode is input
swi SWI_Open @ open file for input
ldr r1,=InFileHandle
str r0,[r1]
ldr r7,[r1]
ldr r1,=array
mov r2,#85
swi SWI_RdStr @stores the string into =array 
bcs EofReached
mov r5,#0 @r5 is index

loop: @processes a single char then loops back
ldrb r4,[r1,r5] @loads the character value from =array[r5] into r4
cmp r4,#0
BEQ newline
cmp r4,#32
beq skip 
cmp r4,#96
bgt lowercase
cmp r4,#91
blt uppercase

uppercase:
cmp r4,#77
ble add 
cmp r4,#91
blt sub 

lowercase:
cmp r4,#109
ble add 
cmp r4,#123
blt sub 

add: 
add r4,r4,#13
b skip

sub:
sub r4,r4,#26
add r4,r4,#13 

skip:
mov r0,r4
swi SWI_PrChr
strb r4,[r1,r5]
add r5,r5,#1
b loop
newline:
bcs EofReached
mov R0,#Stdout @ print new line
ldr r1,=NL
swi SWI_PrStr

bal loop 

swi SWI_Close
swi SWI_Exit
EofReached:
mov R0, #Stdout @ print last message
ldr R1, =EndOfFileMsg
swi SWI_PrStr
Exit:
swi SWI_Exit @ stop executing

.data
 InFileName: .asciz "lab2.txt"
 EndOfFileMsg: .asciz " End of file reached\n"
ColonSpace: .asciz": "
NL: .asciz "\n" @ new line
    .array: .skip 85
  .align
   InFileHandle: .word 0


.end
任何了解ARMSIM的人都可以随时提供帮助 我用这个例子来帮助我
示例11.2但如果没有帮助,程序在一行结束后停止读取

设置一些战略性断点并逐步解决问题是您应该做的第一件事。我自己刚刚尝试过(在修正了
.array:
中的输入错误后)-注意当您跳转到
换行代码:
时会发生什么,并且代码会完全按照您在给定情况下告诉它的方式执行;)你的问题到底是什么?我的问题是为什么我的程序不读取lab2.txt中第一行之外的任何其他行@正如我所说,这一点可以在一分钟的简单调试中得到回答:当您在行结束后到达空字节时,您将跳转到设置了进位标志的
换行
,因为您已告诉它将其解释为文件的结尾,所以它将停止。这不是一个很有趣的答案。设置一些战略断点并逐步解决问题是你应该做的第一件事。我自己刚刚尝试过(在修正了
.array:
中的输入错误后)-注意当您跳转到
换行代码:
时会发生什么,并且代码会完全按照您在给定情况下告诉它的方式执行;)你的问题到底是什么?我的问题是为什么我的程序不读取lab2.txt中第一行之外的任何其他行@正如我所说,这一点可以在一分钟的简单调试中得到回答:当您在行结束后到达空字节时,您将跳转到设置了进位标志的
换行
,因为您已告诉它将其解释为文件的结尾,所以它将停止。这不是一个很有趣的答案。