有问题或有错误可评论留言或咨询QQ:1270082767
第一个:显示字符串
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 si
push cx
mov ax,0b800h
mov es,ax
mov al,160
mul dh ;算行
mov bx,ax
mov al,2
dec dl
mul dl;算列
add bx,ax;先保存总的偏移地址
mov al,cl ;首先保存颜色
s:mov cl,[si]
jcxz ok
mov es:[bx],cl
mov es:[bx+1],al
inc si
add bx,2
jmp short s
ok:
pop cx
pop si
pop dx
pop es
pop ax
ret
code ends
end start
第三个 数值显示
assume cs:code,ds:data
data segment
db 10 dup (0)
data ends
code segment
start: mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax,4c00h
int 21h
show_str:
push ax
push es
push dx
push si
push cx
mov ax,0b800h
mov es,ax
mov al,160
mul dh
mov bx,ax
mov al,2
dec dl
mul dl
add bx,ax
mov al,cl
s:mov cl,[si]
mov ch,0
jcxz ok
mov es:[bx],cl
mov es:[bx+1],al
inc si
add bx,2
jmp short s
ok:
pop cx
pop si
pop dx
pop es
pop ax
ret
dtoc: push ax
push cx
push bx
push si
mov si, 0
mov bx, 10
change: mov dx, 0
div bx
mov cx, ax
add dx, 30H
push dx
* inc si
jcxz last
jmp short change
last:
mov cx, si
mov si, 0
s00:pop ds:[si]
inc si
loop s00
exit: pop si
pop bx
pop cx
pop ax
ret
code ends
end start
//倒序是一个关键