学习高德纳,先用铅笔在纸上写出算法好像真是不错的注意~
; e10_2.asm
assume cs:code,ss:stack
stack segment
db 16 dup (0)
stack ends
code segment
start:
mov ax,stack
mov ss,ax
mov sp,16
mov ax,1000h
mov dx,10h
mov cx,3
call divdw
mov ax,4c00h
int 21h
divdw:
push bx
push ax ; save (ax) = L
mov ax,dx ; calculate H / N
mov dx,0
div cx
mov bx,ax ; result (ax) = int(H/N), save it to (bx)
; (dx) = rem(H/N)
pop ax ; let (ax) = L
div cx ; calculate [rem[H/N] * 65526 + L]/N
mov cx,dx ; (cx) = remainder
mov dx,bx ; (dx) = (bx) = int(H/N)
pop bx
ret
code ends
end start