0

hi guys

i'm trying to write a code that will ask a user to input a string and then check to see if its a palindrome

when trying to run what i have done so far i get an illegal instruction error. i know its something to do with 'get input value' part but i dont know what. also could someone tell me if my inString variable is set correctly.. its supposed to reserve space in memory for 20 char's and a carriage return

JMP START
chword 		DB cr,lf,'Enter a word to see if its a palindrome $'
isNotP 		DB cr,lf,'is not a palindrome$'
isP 		DB cr,lf,'is a palindrome$'
inString	DB cr,lf,	20,?,'                     $'
	

	
	
Start:

;DISPLAY THE FIRST MESSAGE
	LEA DX,chword
	MOV AH,9
	INT 21H
;GET INPUT VALUE
	LEA DX,inString
	MOV AH,0AH
	INT 21H

i have only been learning assembly a few weeks and its not going too good, i think large class sizes at uni and a lack of proper explanation is my biggest problem, so if anyone is willing to help it would be greatly apreciated:cheesy:

2
Contributors
1
Reply
2
Views
10 Years
Discussion Span
Last Post by mathematician
0

hi guys

i'm trying to write a code that will ask a user to input a string and then check to see if its a palindrome

when trying to run what i have done so far i get an illegal instruction error. i know its something to do with 'get input value' part but i dont know what. also could someone tell me if my inString variable is set correctly.. its supposed to reserve space in memory for 20 char's and a carriage return

JMP START
chword         DB cr,lf,'Enter a word to see if its a palindrome $'
isNotP         DB cr,lf,'is not a palindrome$'
isP         DB cr,lf,'is a palindrome$'
inString    DB cr,lf,    20,?,'                     $'
 
 
 
 
Start:
 
;DISPLAY THE FIRST MESSAGE
    LEA DX,chword
    MOV AH,9
    INT 21H
;GET INPUT VALUE
    LEA DX,inString
    MOV AH,0AH
    INT 21H

i have only been learning assembly a few weeks and its not going too good, i think large class sizes at uni and a lack of proper explanation is my biggest problem, so if anyone is willing to help it would be greatly apreciated:cheesy:

You have put a pretty strange place to put a cr, lf. Presumably it is meant to come ate the end of isP:

isP db cr, lf, 'is a palindrome', cr, lf, '$'

Also if instring is meant to be a buffer to hold a maximum of 20 characters plus cr, the best way to declare it is:

instring db 20, ?, 21 dup(?)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.