EASy68K
http://www.easy68k.com/EASy68Kforum/

Help needed for ASCII code
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1041
Page 1 of 1

Author:  DCKK84 [ Mon Aug 15, 2011 10:24 am ]
Post subject:  Help needed for ASCII code

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.

Author:  profkelly [ Mon Aug 15, 2011 11:34 pm ]
Post subject: 

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).

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/