Search code examples
assemblyx86asciidosx86-16

way to display data from bufor assembly 8086


I have program in assembly 8086. I have to load from text file one char and load it to procedure. I have problem with access data in bufor i want to take ascii code of this char.

            mov cx,0        
            mov dx,0       
petla:
            mov ax,4200h
            int 21h


            mov dx,offset Text
            mov cx,1
            mov ah,3fh          
            int 21h  

            mov dx,offset Text
            mov ah,9h           
            int 21h
            mov dx,offset Text
            mov Ton,dl
            call Sound         

            inc licznik
            mov dx,counter
            mov cx,0
            cmp dx,lenght
            JNZ petla
.
.
.
Text db 30000 dup ('$') ;

i want to get char ascii number to in this part:

mov Ton, This Ascii

This program iterate on text line in my txt file. Its look like this

Hello word
0 -> H
1 -> e
2 -> l
3 -> l

This chars saves in buffor Text and in registry all the time i have 000F


Solution

  • Text db 30000 dup ('$') ;
    

    defines a very large buffer, but

    mov dx,offset Text
    mov Ton,dl
    

    will load your Ton variable with the low byte of the offset address of the buffer. That's going to be the same value always, as you have found out.

    To get the first character that is stored in the buffer, you need to write (MASM syntax):

    mov al, Text
    mov Ton, al
    

    You are not limited to the above only, although it is the preferred way.
    Next snippets can work too. Just for giving an idea:

    mov si, offset Text
    mov dl, [si]
    mov Ton, dl
    

    and also

    mov si, offset Text
    mov di, offset Ton
    movsb                 ; Expects DS == ES