汇编显示彩色字

参考《汇编语言》-- 王爽

data segment    
    s1 db "welcome "      
    l1 equ $-s1
    s2 db "to "
    l2 equ $-s2
    s3 db "fasm!"
    l3 equ $-s3
    
    green db 00000010b   ;green 
    green1 db 00001010b  ;green highlight
    rg db 00100100b  ;red on green
    bw db 01110001b  ;blue on white    
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:     
    mov ax,data
    mov ds,ax
    mov ax,0b800h   ; mem for display
    mov es,ax
    
    lea bx,s1   ;data index
    xor bp,bp   ;display index
    mov cx,l1 
show1:               
    mov al,[bx]
    mov es:[bp],al
    mov al,green
    mov es:[bp+1],al      
    inc bx
    add bp,2
    loop show1
    
    
    lea bx,s2   ;data index    
    mov cx,l2 
show2:               
    mov al,[bx]
    mov es:[bp],al
    mov al,rg
    mov es:[bp+1],al      
    inc bx
    add bp,2
    loop show2       
    
    lea bx,s3   ;data index    
    mov cx,l3 
show3:               
    mov al,[bx]
    mov es:[bp],al
    mov al,bw
    mov es:[bp+1],al      
    inc bx
    add bp,2
    loop show3
            
    mov ax, 4c00h ; exit to operating system.
    int 21h    
ends

end start ; set entry point and stop the assembler.

 

你可能感兴趣的:(汇编)