Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ARM Assembly Console Error

Status
Not open for further replies.

dalecprr

Programmer
Dec 16, 2013
1
0
0
IE
I was trying to make a simple program which will read in two strings entered by the user via the console, store the two strings in memory and then compare them to see are they anagrams of each other. However I keep having bizarre errors while trying to echo the characters entered by the user back to the console. Sometimes in the first string letters are echoed to the console twice eg 'ttaacoss' but with no regular pattern, and they are often not stored in memory correctly. I thought this might be a syntax error however the second loop which reads/stores/echoes the characters for the second string is almost identical and functions perfectly. Can anyone help? Relevant code is as follows:
AREA Anagrams, CODE, READONLY
IMPORT main
IMPORT getkey
IMPORT sendchar
EXPORT start

start
LDR R1, =str
LDR R2, =strB
LDR R7, =0
LDR R8, =0

LDR R3,= firstMessage
printFirstMessage
LDRB R0, [R3]
CMP R0, #0
BEQ endFirstMessage
BL sendchar
ADD R3, R3, #1
B printFirstMessage
endFirstMessage

strFirstString
BL getkey
CMP R0, #0x0D
BEQ endstrFirstString
MOV R3, R0
STRB R3, [R1, R8]
ADD R8, R8, #1
BL sendchar
LDR R0, =0
B strFirstString
endstrFirstString
ADD R8, R8, #1
STRB R7, [R1, R8]

LDR R3, =secondMessage
printSecondMessage
LDRB R0, [R3]
CMP R0, #0
BEQ endSecondMessage
BL sendchar
ADD R3, R3, #1
B printSecondMessage
endSecondMessage

strSecondString
BL getkey
CMP R0, #0x0D
BEQ endstrSecondString
BL sendchar
STRB R0, [R2, R7]
ADD R7, R7, #1
B strSecondString
endstrSecondString
LDR R8, =0
ADD R7, R7, #1
STRB R8, [R2, R7]
.............................
AREA TestData, DATA, READWRITE
firstMessage DCB "Enter the first word: ", 0
secondMessage DCB " Enter the second word: ", 0
str SPACE 128
strB SPACE 128
END
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top