Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

accept sting and display second character of string

  Asked By: Quah    Date: Nov 27    Category: Assembly Language    Views: 1183
  

HI...recently i have write a program that require a user key in a string of words and then display only the second character of the words on the screen...im am using TASM and TLINK...i only know that 0AH if for accept string and 02H is for display single character...but i have no idea to do it...could anyone can help me? TQ so much. This is my code...
but it got error...can anyone help me to solve this? TQ



.model small
.stack 64
.data

prompt1 db "Please Enter String:$"
prompt2 db "The second character of string:$"

storeroom label byte
max db 20
actual db ?
data_input db 20 dup("")
;**********************************************

.code
main proc far

mov ax,@data;
mov ds,ax;

mov ah,09h;
lea dx,prompt1;
int 21h;

mov ah,0ah;
lea dx,storeroom;
int 21h;

mov ah,09h
lea dx,prompt2;
int 21h;

mov ah,02h;

mov dl,data_input+1;
int 21h;

main endp;

end main;


Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abhishek Singh     Answered On: May 23



down vote
accepted you'd need to dereference the pointer to get the actual character:

mov eax, OFFSET operandA+1
mov cl,byte ptr [eax]
cmp cl,'!'
or

mov eax, OFFSET operandA
mov cl,byte ptr [eax + 1]
cmp cl,'!'
this preserves eax so you can compare the second char using:

inc eax
mov cl,byte ptr [eax]
cmp cl,'?'
or

mov cl,byte ptr [eax + 2]
cmp cl,'?'

 
Didn't find what you were looking for? Find more on accept sting and display second character of string Or get search suggestion and latest updates.




Tagged: