; 在屏幕上输出内存单元中的十进制两位数
assume cs:code, ds:data
data segment
db 12
db 0,0 ; 前一个字节用于保存商,后一个字节用于保存余数
data ends
code segment
start:
mov ax,data
mov ds,ax ; 补全指令,使得ds <-- data段地址
mov ah,0
mov al,ds:[0] ; ax <-- data段字节单元的被除数12
mov bl,10
div bl
mov ds:[1],al ; 补全代码,让商保存到data段注释中指定的单元
mov ds:[2],ah ; 补全代码,让余数保存到data段注释中指定的单元
mov ah,2
mov dl,ds:[1] ; 补全代码,使得dl <-- data段中保存的商的字节单元数值
add dl, 30h ; 补全代码,使得dl中的数值转换为数字字符
int 21h
mov ah,2
mov dl,ds:[2] ; 补全代码,使得dl <-- data段中保存余数的字节单元数值
add dl, 30h ; 补全代码,使得dl中的数值转换为数字字符
int 21h
mov ax,4c00h
int 21h
code ends
end start
![1348769-20181208212954724-834719697.png](https://i-blog.csdnimg.cn/blog_migrate/cde8c96dd7a5a41f707e0ac71c472084.png)
assume cs:code, ds:data
data segment
db 12,35,96,55,67
data ends
code segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov cx,5
s:mov ah,0
mov al,[bx]
mov dl,10
div dl ;进行除法运算
mov dh,ah ;将余数放入指定单元
mov dl,al ;将商放入指定单元
mov ah,2
add dl,30h ;将dl中数值转换成数字字符
int 21h
mov dl,dh
mov ah,2
add dl,30h
int 21h
mov dl,20h
mov ah,2
int 21h
inc bx
loop s
mov ax,4c00h
int 21h
code ends
end start
![1348769-20181208220022976-123624866.png](https://i-blog.csdnimg.cn/blog_migrate/493de4f0aafdc286f7ba489791edbfe2.png)
assume cs:code,ds:data
data segment
db 'welcome to masm!'
data ends
code segment
start: mov ax,data
mov ds,ax
mov cl,10h
mov ch,0
mov ax,0B800h
mov es,ax
mov si,0h
mov di,0h
s: mov al,0
mov al,ds:[si]
mov ah,0
mov ah,00000010B
mov es:[720h+di],ax
mov ah,11110001B
mov es:[720h+di+160D],ax
mov ah,10100100B
mov es:[720h+di+320D],ax
inc si
add di,02h
loop s
mov ax,4c00h
int 21h
code ends
end start
![1348769-20181209105608756-769983961.png](https://i-blog.csdnimg.cn/blog_migrate/abca75b092b58aa944c3b454993a47a0.png)