|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
编程一、显示字符串
功能:在指定的位置,用指定的颜色,显示一个用0结束的字符串
assume cs: code
data segment
db 'welcome to masm!', 0
data ends
code segment
start : mov ax, data
mov ds, ax
mov dh, 8
mov dl, 3
mov cl, 2
mov si, 0
call show_str
mov ax, 4c00H
int 21H
show_str : push ax
push bx
push cx
push dx
push si
push di
mov bx, 0
mov ax, 0b800H
mov es, ax
dec dh
mov al, dh
mov dh, 160
mul dh
mov bx, ax
mov al, dl
mov dl, 2
mul dl
add bx, ax
mov ah, cl
mov cl, 0
show : mov al, [si]
mov es:[bx], ax
mov ch, [si]
inc si
add bx, 2
jcxz ok
jmp show
ok: pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
code ends
end start
编程二、决解除法溢出的问题assume cs: code
code segment
start : mov ax, 4240H
mov dx, 000FH
mov cx, 0AH
call divdw
mov ax, 4c00H
int 21H
divdw : push ax
mov ax, dx
mov dx, 0
div cx
mov bx, ax
pop ax
div cx
mov cx, dx
mov dx, bx
ret
code ends
end start
编程三、数值显示
功能:将word型的数据变为十进制的字符串,字符串以0为结束符assume cs: code
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
dtoc : push ax
push bx
push cx
push dx
push si
push di
mov di, 0
d10 : mov dx, 0
mov bx, 10
div bx
add dx, 30H
push dx
inc di
mov cx, ax
jcxz d11
jmp d10
d11: mov cx, di
d12: pop dx
mov [si], dl
inc si
loop d12
mov dl, 0
mov [si], dl
okay: pop di
pop si
pop dx
pop cx
pop bx
pop ax
ret
show_str:mov bx, 0
mov ax, 0b800H
mov es, ax
dec dh
mov al, dh
mov dh, 160
mul dh
mov bx, ax
mov al, dl
mov dl, 2
mul dl
add bx, ax
mov ah, cl
mov cl, 0
show : mov al, [si]
mov es:[bx], ax
mov ch, [si]
inc si
add bx, 2
jcxz ok
jmp show
ok : ret
code ends
end start
|
|