I have this piece of assembly code to accept a string and display the string back.
My problem is I'm not able to figure out how exactly the name is getting stored in name1 as we are using buff to store the input from the user.
I know that
buff label byte
maxchar db 50
readchar db 0
name1 db 48 dup(0)
is got something to do with this. But I'm not able to understand the working.
.model small
.stack
.data
buff label byte
maxchar db 50
readchar db 0
name1 db 48 dup(0)
m1 db 10,13,"enter name: $"
m2 db 10,13,"your name is: $"
.code
mov ax, @data
mov ds, ax
lea dx, m1
mov ah, 09
int 21h
lea dx, buff
mov ah, 10
int 21h
mov ah,0
mov al, readchar
add ax, 2
mov si, al
mov buff[si],24H ;ascii code for $ to terminate string
lea dx, m2
mov ah, 9
int 21h
lea dx, name1
mov ah, 09
int 21h
mov ah, 4ch
int 21h
end
please help!
thank you.