EASy68K  
It is currently Tue Oct 16, 2018 6:11 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Aug 15, 2011 10:24 am 
Offline

Joined: Sun Aug 14, 2011 6:56 am
Posts: 1
Location: Singapore
Hi

I am trying to figure out the assignment that I am given, the objectives are:

To compare 2 strings 'Computer Hardware' and 'Comppuuter Haardware'.

A string to store at $600 and a second string of equal length to store at $700. Having each string to end with $0D. Write an assembly program to determine whether the strings are identical. If they are identical, place $00 in data register D0. If they are not, place $FF in D0.

I have tried writing the program codes, but I can't make it produce the result that is needed.

ORG $600
X DC.W 'COMPUTER HARDWARE'
ORG $700
Y DC.W 'COMPPUUTER HAARDWARE'
START:



MOVEA #X,A0 *A0 POINT AT BASE OF ARRAY X
MOVE.W (A0),D1
MOVEA #Y,A1 *A1 POINT AT BASE OF ARRAY Y
MOVE.W (A1),D2
CMP D1,D2 *COMPARE X AND Y
BNE ELSE
MOVE.W #$00,D0
ELSE MOVE.W #$FF,D0


MOVE.B #9,D0
TRAP #15 ; halt simulator





END START ; last line of source

Sorry for my bad programming, badly need help over here. Thank you if you can help me with this set of program codes.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2011 11:34 pm 
Online
User avatar

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1083
Use a loop to iterate through the strings character by character.

CMP D1,D2 *COMPARE X AND Y does a 16 bit compare. It should be
CMP.B D1,D2

Stop the loop when the two characters being compared are different (the strings are not equal) or when $0D is reached on both strings (the strings are equal).

_________________
Prof. Kelly


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group