Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

NOTICE! IF YOU ARE GOING TO ANSWER! READ MY PROGRAM FIRST I\'m supposed to make

ID: 3757651 • Letter: N

Question

NOTICE! IF YOU ARE GOING TO ANSWER! READ MY PROGRAM FIRST

I'm supposed to make program in EASy68K, that checks if string is palindrome or not! I've already done that!

How can i make it also count the length and print it out?

*-----------------------------------------------------------
* Title :
* Written by :
* Date :
* Description:
*-----------------------------------------------------------
ORG $1000
START: ; first instruction of program

mainLoop move.b #14,d0
lea enterStrMsg,a1
trap #15

LEA input, a1
move.b #2,d0
trap #15

move.b d1, d5
move.w a1, a2
add.w d1, a2
cmp #$24,(a1)
bne loopPalindrome

loopPalindrome
move.b -(a2),d3
move.b (a1)+,d4
cmp d3,d4   
bne notPalindr
sub.b #1,d5   
cmp #0,d5
bhi loopPalindrome   
bsr isPalindr   

STOP #$2000   

isPalindr
move.b #14,d0
lea paliMsg,a1   
trap #15
bra mainLoop


notPalindr
move.b #14,d0
lea notPaliMsg,a1
trap #15
bra mainLoop





SIMHALT ; halt simulator





CR EQU $0D
LF EQU $0A


enterStrMsg dc.b CR,LF,'Enter string: ',0
notPaliMsg dc.b CR,LF,'Is not palindrome! ',0
paliMsg dc.b CR,LF,'is palindrome! ',0


input ds.b $2000
* Put variables and constants here

END START ; last line of source

Explanation / Answer


ORG $1000
START: ; first instruction of program
mainLoop move.b #14,d0
lea enterStrMsg,a1
trap #15

LEA input, a1
move.b #2,d0
trap #15

move.b d1, d5
move.w a1, a2
add.w d1, a2
cmp #$24,(a1)
bne loopPalindrome

loopPalindrome
move.b -(a2),d3
move.b (a1)+,d4
cmp d3,d4   
bne notPalindr
sub.b #1,d5   
cmp #0,d5
bhi loopPalindrome   
bsr isPalindr   

STOP #$2000   

isPalindr
move.b #14,d0
lea paliMsg,a1   
trap #15
bra mainLoop


notPalindr
move.b #14,d0
lea notPaliMsg,a1
trap #15
bra mainLoop

SIMHALT ; halt simulator

CR EQU $0D
LF EQU $0A
MAXLEN DB 100

enterStrMsg dc.b CR,LF,'Enter string: ',0
notPaliMsg dc.b CR,LF,'Is not palindrome! ',0
paliMsg dc.b CR,LF,'is palindrome! ',0
lengthMsg dc.b CR,LF,'The length is ',0

LEA DX,ACT_DATA
MOV AH,0AH
MOV DX,OFFSET MAXLEN
lea lengthMsg,a1
INT 21H

input ds.b $2000

END START ; last line of source