王爽 汇编语言 第十章 实验十

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 bx
	push cx
	push dx
	push si

	mov ah,0
	mov al,dh
	mov dh,0Ah
	mul dh
	
	add ax,0b800h
	mov es,ax
	
	mov al,dl
	mov dl,2
	mul dl
	mov bx,ax
	
s:
	mov al,ds:[si]
	cmp al,0
	je ok
	mov ah,cl
	
	mov es:[bx],ax
	
	inc si
	add bx,2
	jmp s
	
	ok:
		
	pop si
	pop dx
	pop cx
	pop bx
	pop ax
	
	ret 
code ends
end start

2、除法溢出

assume cs:code 
code segment 
start:
	mov ax,4240h
	mov dx,000fh
	mov cx,0ah
	call divdw
	
	mov ax,4c00h
	int 21h
divdw:
	push bx
	
	mov bx,ax
	mov ax,dx
	mov dx,0
	div cx
	
	push ax
	mov ax,bx
	div cx
	mov cx,dx
	pop dx
	
	pop bx
	ret
code ends
end start

王爽 汇编语言 第十章 实验十_第1张图片

3、数值显示

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 dx
	push cx
	push si
	
	mov cx,11
	push cx
	mov cx,10
s:	mov dx,0
	div cx
	push dx
	cmp ax,0
	jne s
	
s1:
	pop ax
	add ax,30h
	mov ds:[si],ax
	inc si
	cmp ax,3Bh
	jne s1
	
	sub si,1
	mov ax,0
	mov ds:[si],ax
		
	pop si
	pop cx
	pop dx
	ret

show_str:
	push ax
	push bx
	push cx
	push dx
	push si

	mov ah,0
	mov al,dh
	mov dh,0Ah
	mul dh
	
	add ax,0b800h
	mov es,ax
	
	mov al,dl
	mov dl,2
	mul dl
	mov bx,ax
	
s2:
	mov al,ds:[si]
	cmp al,0
	je ok
	mov ah,cl
	
	mov es:[bx],ax
	
	inc si
	add bx,2
	jmp s2
	
	ok:
		
	pop si
	pop dx
	pop cx
	pop bx
	pop ax
	
	ret 
code ends
end start

王爽 汇编语言 第十章 实验十_第2张图片
其他实验题答案:实验题答案合集

你可能感兴趣的:(汇编语言,王爽,王爽,汇编,实验十,数值显示)