Write a 68000 assembly program to compare two strings of 15 ASCII characters. Th
ID: 2085012 • Letter: W
Question
Write a 68000 assembly program to compare two strings of 15 ASCII characters. The first string is stored starting at $502030. The second string is stored at location $302510. The ASCII character in location $502030 of string 1 will be compared with the ASCII character in location $302510 of string 2, [$502031] will be compared with [$302511], and so on. Each time there is a match, store $EEEE onto the stack; otherwise, store $0000 onto the stack. Assume user mode.
PLEASE DO USING 68000 MOTOROLA ASSEMBLY LANGUAGE. I HAVE SOME OTHER METHODS BUT I HAVE BEEN CHECKING THEM AND ITS NOT WORKING LIKE I THOUGHT :( HELP!
Explanation / Answer
Code of the asked quesion is given below
=====>
START:
LEA $502030,A3 ; load first string in A3
LEA $302510,A4 ; load 2nd string in A4
MOVE.B #0,D4
LOOP:
ADD.B #1,D4
MOVE.B (A4)+,D1
MOVE.B (A3)+,D2
CMP.B #0,D1
BEQ CHECKAGAIN
CMP.B #0,D2
BEQ NOTEQU
CMP.B D1,D2
BEQ LOOP
BNE NOTEQU
EQU:
LEA MES2,A1
MOVE.B #14,D0
TRAP #15
BRA EXIT
CHECKAGAIN:
CMP.B #0,D2
BEQ EQU
NOTEQU:
LEA MES1,A1
MOVE.B #14,D0
TRAP #15
LEA MES3,A1
MOVE.B #14,D0
TRAP #15
MOVE.W D4,D1
MOVE.B #3,D0
TRAP #15
EXIT:
MOVE.B #9,D0
TRAP #15
MES1 DC.B 'STRINGS DON'T MATCH',$0D,$0A,0
MES3 DC.B 'AT ',0
MES2 DC.B 'STRINGS MATCH',0
END START
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.