a86 Palindrome

awuja 0 Tallied Votes 660 Views Share

Hey guys.. need some help with this; I'm pulling my hair out.. i've trawled these boards but can't find anything that answers my question.

I, like many others before me (so it seems!) am trying to create a program to check for a palindrome.. this is what I have so far.

In the compare part.. it's just not working. I know I'm doing something wrong with SI and DI.. I just don't know what.

Any explanations would be greatly appreciate! :)

Thanks,

awuja

JMP START

CR equ 13 ; RETURN is 13D ASCII
LF equ 10 ; LINE FEED is 10D ASCII

letterUnitCount DB 0
letterTensCount DB 0
vowelCount DB 0

getWord: DB "Please enter a word",CR, LF,"$"
letterCountMessage: DB CR, LF, "Number of Characters: ", "$"

msg1: DB CR, LF, "  this is palindrome!", "$"
msg2: DB CR, LF, "  this is not a palindrome!", "$"

inWord: DB 128 DUP (0)

START: 
	LEA DX,getWord ;Output string asking user for word
	MOV AH,09h ;DOS call to output string
	INT 21H ;Execute interrupt 21H

KEYBUF: 
	LEA DI,inWord ;Load inWord start address into DI

NEXTCHAR: 
	MOV AH,01h
	INT 21H ;Read key pressed and echo to screen
	
	CMP letterUnitCount, 10
	JE ROLLOVER
		
UNIT:	
	INC letterUnitCount
	
		
	;CMP AL, 65
	;JE INCRVOWEL
	;CMP AL, 97
	;JE INCRVOWEL
	
STORE:	
	MOV [DI],AL ;store in inWord at position [DI]
	INC DI ;Make DI point to next byte in inWord
	CMP AL,0Dh ;Was it the carriage return key?
	JNZ NEXTCHAR ;NO, get some more characters
	MOV [byte ptr DI],"$" ;YES, add end of string marker
	
	MOV SI, DI
	
COMPARE:

	ADD SI, DI
	DEC SI
	
	MOV AL, [DI]
	
	MOV DL, AL
	MOV AH, 2
	INT 21h
	
	MOV BL, [SI]
	
	MOV DL, BL
	MOV AH, 2
	INT 21h
	
	CMP AL,BL
	JNE NOTPAL
	
	INC DI
	DEC SI
LOOP COMPARE

ISPAL:	
	MOV DX, msg1
	MOV AH, 09h
	INT 21h
	
NOTPAL:
	MOV DX, msg2
	MOV AH, 09h
	INT 21h
robertospartan 0 Newbie Poster

in case anyone has the need for such an example, I found one [here]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.