Solved

Palindrome?

Posted on 2003-11-19
7
2,373 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
7 Comments
 
LVL 1

Accepted Solution

by:
vbs03 earned 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to Replace 2003 failover Cluster node 4 355
query on MOV assembly instruction 6 568
File Not Found Exception 12 109
SQL Server RDS clr assembly 4 50
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now