1. 显示字符串
1 assume cs:code 2 3 data segment 4 db ‘Welcome to masm!‘,0 5 data ends 6 7 stack segment 8 db 16 dup (0) 9 stack ends 10 11 code segment 12 start: 13 mov dh,8 14 mov dl,3 15 mov cl,2 16 mov ax,data 17 mov ds,ax 18 mov si,0 19 call show_str 20 21 ;一直循环 22 all: 23 jmp short all 24 25 mov ax,4c00h 26 int 21h 27 28 show_str: 29 mov bl,1 30 mov al,dh 31 sub al,bl 32 ;(n行-1)*160=n行开头的偏移地址 33 mov bl,160 34 mul bl 35 mov bx,0b800h 36 mov es,bx ;显存的段地址放在es 37 mov bx,ax ;行 38 mov dh,0 39 ; (n列-1)*2=当前列的偏移地址 40 mov di,dx 41 sub di,1 42 add di,di 43 ;颜色设置 44 mov ch,0 45 mov dx,cx 46 s: 47 mov cl,[si] 48 mov ch,0 49 jcxz ok 50 mov ax,[si] 51 mov es:[bx+di],ax 52 mov es:[bx+di+1],dx 53 ;一个字母占两个字节,一个ascii 54 add di,2 55 inc si 56 loop s 57 58 ok: 59 ret 60 61 code ends 62 end start
图片显示:
原文地址:https://www.cnblogs.com/Triomphe/p/8545461.html
时间: 2024-10-15 10:31:33