王爽《彙編語言》實驗10:編寫子程序divdw 解答


assume cs:code

stack segment

	dw 8 dup(0)
	
stack ends

code segment
start:	
	mov ax,stack
	mov ss,ax
	mov sp,10h;設置棧段
	mov ax,4240h
	mov dx,0fh
	mov cx,0ah
	call divdw
	
	mov ax,4c00h
	int 21h
	
divdw:
	
	push ax;將ax放進棧保存
	;接下來實現高位的除法
	mov ax,dx
	mov dx,0
	div cx
	
	;把商放進bx中
	mov bx,ax
	pop ax
	div cx
	mov cx,dx;寄存器間的值調整
	mov dx,bx
	
	ret
	
code ends
end start

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章