我正在写一篇关于armim的内容#一切都有效,除了它不会读下一行
.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的人都可以随时提供帮助 我正在用这个例子来帮助我 http://armsim.cs.uvic.ca/AttachedFiles/ARMSim_UserGuide4Plus.pdf示例11.2但无助于程序在一行完成后停止读取