assemblyvideo-memory

why only three word is write on the memory ? assembly language


.model small

.stack 200h

.data   

string1 db 'wahab $'

.code

main proc 

    mov ax,@data
    mov ds,ax
    mov ax,0b800h 

    mov es,ax  

    mov ax,offset string1 
    mov si,ax 
    mov di,0

    l1:

    mov ax,[si]

    mov es:[di],ax 
    inc si
    inc di

    cmp ax,'$'
    jne l1           

    main endp

only three character is display on the screen or video memory ?


Solution

  • Video memory is word-aligned. Even byte is a characted to display, odd byte is color attribute. Thus, when you do mov [es:di], ax to video memory segment, AL holds a character to be displayed, and AH - color of that character.

    l1:
    
    mov al,[si]
    
    mov es:[di],al 
    inc si
    add di, 2
    
    cmp al,'$'
    jne l1