INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ARM Assembly Console Error

ARM Assembly Console Error

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close