I have to extract digit stored in si register. here is my code
lea si, userInput
inc si
mov bx, [si]
mov dx, [si+bx]
add dx, 30h
mov ah, 2h
int 21h
So i think code works fine if i put hard value in dx register like mov dx, [si+2]
but if try to use mov dx, [si+bx]
it does not work and does not give ouput as expected
Assuming your userInput points at the input structure required for DOS's buffered input function 0Ah, these are my recommandations to correct your code:
mov dx, 30h
) The fact that this character could represent a (numerical) digit, a letter, a punctuation mark, or anything else, doesn't change this.Your code then becomes:
lea si, userInput
inc si
mov bl, [si] ;Number of inputted characters
mov bh, 0 ;Need to zero to be able to use the whole address-register BX next
mov dl, [si+bx] ;Retrieve the last inputted character (right before the terminating CR)
mov ah, 02h
int 21h ;Display the character