movp: push cx push ds push si push es push di cmp ax, dx ja .up je .return push ax add ax, cx cmp ax, dx pop ax ja .down .up: push ax push dx .uploop: mov ds, ax mov es, dx xor di, di xor si, si sub cx, 1000h jbe .uplast push cx mov cx, 10000h /2 rep movsw pop cx add ax, 1000h add dx, 1000h jmp short .uploop .uplast: add cx, 1000h shl cx, 1 shl cx, 1 shl cx, 1 rep movsw pop dx pop ax jmp short .return .down: std .dnloop: sub cx, 1000h jbe .dnlast push ax push dx add ax, cx add dx, cx mov ds, ax mov es, dx pop dx pop ax mov di, -2 mov si, di push cx mov cx, 10000h /2 rep movsw pop cx jmp short .dnloop .dnlast: add cx, 1000h shl cx, 1 shl cx, 1 shl cx, 1 mov di, cx dec di shl di, 1 mov si, di mov ds, ax mov es, dx numdef AMD_ERRATUM_109_WORKAROUND, 1 %if _AMD_ERRATUM_109_WORKAROUND jcxz @FF cmp cx, 20 ja @FF @@: movsw loop @B @@: %endif rep movsw cld .return: pop di pop es pop si pop ds pop cx retn