assume cs:code
data segment
db 'Welcome to masm!',0
data ends
code segment
start:
;mov ax,4240h
;mov dx,000fh
;mov cx,0ah
;call divdw
mov ax,data
mov ds,ax
mov dx,0803
mov cl,07
mov si,0
call show_str
mov ax,4c00h
int 21h
show_str:
;制定位置 制定颜色 显示用零结尾的字符串
;dh=行号(0-24)dl=列号(0-79) cl=颜色 ds:si指向字符串首地址
;7 6 5 4 3 2 1 0
;BL R G B I R G B
;闪烁 背景 高亮 前景
;R红色 G绿色 B蓝色
push ax
push bx
push sp
push dx
push cx
push es
mov cl,[si]
mov ch,0
jcxz show_str2_0
mov bp,sp
mov dx,0B800h
mov es,dx
mov al,[bp+5]
mov dx,160
mul dx
mov dl,[bp+4]
mov dh,0
add dx,dx
sub dx,1
add ax,dx
mov bx,ax ;es:[bx] chushi xianshi
mov ax,di ;ah=di
mov di,0
push ax
show_str1:
mov cl,[si]
mov ch,0
jcxz show_str2
mov al,ds:[si]
mov byte ptr es:[bx+di],al
mov al,ss:[bp+2]
mov byte ptr es:[bx+di+1],al
inc si
inc di
inc di
loop show_str1
pop ax
show_str2:
mov di,ax
pop es
pop cx
pop dx
pop sp
pop bx
pop ax
ret
show_str2_0:
pop es
pop cx
pop dx
pop sp
pop bx
pop ax
ret
code ends
end start
data segment
db 'Welcome to masm!',0
data ends
code segment
start:
;mov ax,4240h
;mov dx,000fh
;mov cx,0ah
;call divdw
mov ax,data
mov ds,ax
mov dx,0803
mov cl,07
mov si,0
call show_str
mov ax,4c00h
int 21h
show_str:
;制定位置 制定颜色 显示用零结尾的字符串
;dh=行号(0-24)dl=列号(0-79) cl=颜色 ds:si指向字符串首地址
;7 6 5 4 3 2 1 0
;BL R G B I R G B
;闪烁 背景 高亮 前景
;R红色 G绿色 B蓝色
push ax
push bx
push sp
push dx
push cx
push es
mov cl,[si]
mov ch,0
jcxz show_str2_0
mov bp,sp
mov dx,0B800h
mov es,dx
mov al,[bp+5]
mov dx,160
mul dx
mov dl,[bp+4]
mov dh,0
add dx,dx
sub dx,1
add ax,dx
mov bx,ax ;es:[bx] chushi xianshi
mov ax,di ;ah=di
mov di,0
push ax
show_str1:
mov cl,[si]
mov ch,0
jcxz show_str2
mov al,ds:[si]
mov byte ptr es:[bx+di],al
mov al,ss:[bp+2]
mov byte ptr es:[bx+di+1],al
inc si
inc di
inc di
loop show_str1
pop ax
show_str2:
mov di,ax
pop es
pop cx
pop dx
pop sp
pop bx
pop ax
ret
show_str2_0:
pop es
pop cx
pop dx
pop sp
pop bx
pop ax
ret
code ends
end start