rdos/kernel/far.asm
2021-04-20 16:27:10 +00:00

47 lines
707 B
NASM

; reset segments
rstseg mov ax, cs
mov ds, ax
mov es, ax
ret
; copy to far memory
; IN es:bx far memory ptr (preserved)
; ds:dx local ptr (preserved)
; cx number of bytes to transfer
; OUT cx set to zero
; si & di trashed
stofar mov si, dx
mov di, bx
rep movsb
ret
; copy from far memory
; IN es:bx far memory ptr (preserved)
; ds:dx local ptr (preserved)
; cx number of bytes to copy
; OUT cx set to zero
; si & di trashed
lodfar call xchgdes
mov si, bx
mov di, dx
rep movsb
; exchange es and ds
xchgdes push ds
push es
pop ds
pop es
ret
; normalize ptr in ds:dx
norm mov ax, ds
mov cl, 4
push dx
ror dx, cl
and dh, 0xF
add ax, dx
mov ds, ax
pop dx
and dx, 0xF
ret