Solved

Palindrome?

Posted on 2003-11-19
7
2,397 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
Let's take a look back at the commercialization of the internet to understand why keeping it open and neutral is in our best interest as a society.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 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