Palindrome?

Dear All,

Can anyone teach me how to write a 68000 assembly language programme which will check whether a string is palindrome or not?

Thanks!
cplauAsked:
Who is Participating?
 
vbs03Commented:
Hi just go through the following code written for x86

        .MODEL SMALL
        .STACK 64
        .DATA
STRPAR LABEL   BYTE
MAXLEN  DB      20
ACTLEN  DB      ?
STR1     DB      20 DUP ('-')

REVSTR  DB      20 DUP ('-')
PROMPT  DB      ' ENTER THE STRING : ','$'

PAMSG   DB      0DH,0AH,' THE ENTERED STRING IS A PALINDROME ! ','$'
NPAMSG  DB      0DH,0AH,' THE ENTERED STRING IS NOT A PALINDROME ! ','$'

        .CODE
BEGIN   PROC    NEAR
        MOV     AX,@DATA
        MOV     DS,AX
        MOV     ES,AX
        CALL    CLRSCR
        CALL    SETCUR
        CALL    ACCSTR
        CALL    REV
        MOV     AH,02H
        MOV     BH,00H
        MOV     DX,1240H
        CALL    CHECKP
        MOV     AX,4C00H
        INT     21H
BEGIN   ENDP

CLRSCR  PROC    NEAR
        MOV     AX,0600H
        MOV     BH,0CH
        MOV     CX,0000H
        MOV     DX,184FH
        INT     10H
        RET
CLRSCR  ENDP

SETCUR  PROC    NEAR
        MOV     AH,02H
        MOV     BH,00H
        MOV     DX,0000H
        INT     10H
        MOV     AH,01H
        MOV     CH,10
        MOV     CL,14
        INT     10H
        RET
SETCUR  ENDP

ACCSTR  PROC    NEAR
        MOV     AH,09H
        LEA     DX,PROMPT
        INT     21H
        MOV     AH,0AH
        LEA     DX,STRPAR
        INT     21H
        MOV     BH,00H
        MOV     BL,ACTLEN
        MOV     AL,'$'
        MOV     [STR1+BX],AL
        RET
ACCSTR  ENDP

REV     PROC    NEAR
        MOV     BH,00
        MOV     BL,ACTLEN
        LEA     DI,STR1
        LEA     SI,[DI+BX]
        LEA     DI,REVSTR
        MOV     CH,00
        MOV     CL,ACTLEN
        DEC     SI
ACTREV :
        MOV     AL,[SI]
        MOV     [DI],AL
        INC     DI
        DEC     SI
        LOOP    ACTREV
        MOV     AL,'$'
        MOV     [DI],AL
        MOV     AH,09H
        LEA     DX,REVSTR
        INT     21H
        MOV     AH,02H
        MOV     BH,00H
        MOV     DX,0640H
        INT     10H

        RET
REV     ENDP

CHECKP  PROC    NEAR
        CLD
        MOV     CH,00
        MOV     CL,ACTLEN
        DEC     CX
        LEA     SI,STR1
        LEA     DI,REVSTR
        REPE    CMPSB
;        CMP     CX,0000H
        JE      PMSG
        MOV     AH,09H
        LEA     DX,NPAMSG
        INT     21H
        JMP     CEND
PMSG :
        MOV     AH,09H
        LEA     DX,PAMSG
        INT     21H
CEND :
        RET
CHECKP  ENDP
        END     BEGIN

If u need detailed instructions please post ur query. Hope this helps.
Regards
VBS



0
 
kenspencerCommented:
Hi,
vbs03 -- Just a comment.   Why bother creating a second string?  After you establish SI/DI pointing at the beginning/end of the input string then you could perform a compare and jump out of the loop on a 'not equal' condition.

Ken
0
 
DaramarakCommented:
Hm... sounds like homework to me (I might ofcourse be wrong).
0
 
SaintslayerCommented:
can anyone tell me how to write a LC-3 assembly language to check whether a string is palindrome or not?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.