48 lines
596 B
NASM
48 lines
596 B
NASM
; Utilities to help with far pointers
|
|
|
|
; exchange DS:SI with ES:DI
|
|
xchgs: push ds
|
|
push es
|
|
pop ds
|
|
pop es
|
|
xchg si, di
|
|
ret
|
|
|
|
; far pointer load
|
|
; IN ES:BX far pointer to data
|
|
; CX number of bytes to copy
|
|
; 0:DX destination buffer
|
|
|
|
lod: push es
|
|
|
|
; ES:DI := DS:DX
|
|
mov ax, ds
|
|
mov es, ax
|
|
mov di, dx
|
|
; DS:SI := 0:BX
|
|
xor ax, ax
|
|
mov ds, ax
|
|
mov si, bx
|
|
; copy
|
|
pushf
|
|
cld
|
|
rep movsb
|
|
popf
|
|
; reset DS to kernel data
|
|
mov ds, cx
|
|
|
|
pop es
|
|
ret
|
|
|
|
; far pointer store
|
|
; IN ES:BX far ptr
|
|
; CX number of bytes
|
|
; 0:DX source buffer
|
|
; only CX is trashed
|
|
|
|
sto: mov si, dx
|
|
mov di, bx
|
|
cld
|
|
rep movsb
|
|
ret
|