Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Palindrome?

Posted on 2003-11-19
7
Medium Priority
?
2,439 Views
Last Modified: 2012-06-27
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!
0
Comment
Question by:cplau
4 Comments
 
LVL 1

Accepted Solution

by:
vbs03 earned 800 total points
ID: 9785884
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
 
LVL 3

Expert Comment

by:kenspencer
ID: 9827527
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
 

Expert Comment

by:Daramarak
ID: 9908964
Hm... sounds like homework to me (I might ofcourse be wrong).
0
 

Expert Comment

by:Saintslayer
ID: 13190790
can anyone tell me how to write a LC-3 assembly language to check whether a string is palindrome or not?
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question