1.顯示字符串
完整源碼
assume cs:code
data segment
db 'welcome to masm!',0
data ends
code segment
start: mov dh,8
mov dl,3
mov cl,2
mov ax,data
mov ds,ax
mov si,0
call show_str
mov ax,4c00H
int 21H
show_str: push ax
push es
push dx
push bx
push cx
push si
push di
mov ax,0b800h
mov es,ax
dec dh
mov al,160
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
mov dl,cl
mov di,0
show: mov cl,[si]
mov ch,0
jcxz ok
mov es:[bx+di],cl
mov es:[bx+di+1],dl
inc si
add di,2
jmp short show
ok: pop di
pop si
pop cx
pop bx
pop dx
pop es
pop ax
ret ;子程序調(diào)用 返回
code ends
end start
代碼說明
- 行號(hào)(取值范圍 0~24)拄养,第8行是相對(duì)第0行起算的离斩;
- 列好(取值范圍 0~79),第3列是相對(duì)第0列起算的瘪匿;
代碼參考
- 子程序結(jié)構(gòu) http://www.reibang.com/p/ee49618262fd
- 乘法指令 http://www.reibang.com/p/76ed79d0a7a0
- 顯存顯示字符串設(shè)置顏色屬性 http://www.reibang.com/p/b3367173680c