READ A STRING - MICROPROCESSOR 8086 - Code Developer Pro

magma

Solutions to all coding problems

Like us on Facebook

demo-image

Post Top Ad

Responsive Ads Here

Post Top Ad

Sunday, 28 June 2015

READ A STRING - MICROPROCESSOR 8086

Responsive Ads Here


How to read a string using Assembly Language program using 8086 Microprocessor?
Solution
Intel-Celebrates-the-40th-Anniversary-of-the-Microprocessor-3
print macro str
       mov ah,09h
       mov dx,offset str
       int 21h
endm
data segment
       arr db 80 dup ('$')
       msg1 db "Enter the string$"
       msg2 db "The string is $"
       nl db 0dh,0ah,'$'
data ends
code segment
       assume ds:data,cs:code
start: mov ax,data
       mov ds,ax
       print msg1
       print nl
       mov si,offset arr
rpt1:  mov ah,01h
       int 21h
       cmp al,0dh
       jz stop1
       mov [si],al
       inc si
       jmp rpt1
stop1: mov [si],'$'
       print nl
       mov si,offset arr
       print msg2
       mov dx,offset arr
       mov ah,09h
       int 21h
       mov ah,4ch
       int 21h
code ends
end start

Output

Enter the string
hello world !
The string is hello world !


No comments:

Post a Comment

Post Top Ad