Mail Archives: djgpp/1996/05/16/18:33:46
>Hello all,
>I have the following question concerning DJGPP (v1.12mt5 and v2):
>What must I do to copy a 64k segment (starting at DC000) into
>an array with the size of [256][256].
>Can someone please post me an example?
I don't have example here, but there are some hints :
1. Create a dpmi segment for your memory area :
short selector=__dpmi_allocate_ldt_descriptors(1);
__dpmi_set_segment_base_address(selector,0xDC000);
__dpmi_set_segment_limit(selector,0xFFFF);
2. When you need to, copy the memory using this selector (the better is using asm) :
ASM.H: void copymem(short selector, void *destination);
ASM.S:
#define ARG1 8(%ebp)
#define ARG2 12(%ebp)
.text
.glob _copymem
_copymem: /* Setup stack frame */
pushl %ebp
movl %esp,%ebp
pushl %edi
pushw %ds
/* Load source position */
movl ARG1,%eax
movw %ax,%ds
xorl %esi,%esi
/* Load destination position */
movl ARG2,%edi
/* Copy */
movl 16384,%ecx
rep movsl
/* Restore stack frame and exit */
popw %ds
popl %edi
popl %ebp
ret
3. Destroy dpmi segment
__dpmi_free_ldt_descriptor(selector);
4. If your 0xdc000 is a hardware memory (card in a slot), you'll probably
want to lock the created segment, so dpmi won't page it out of memory
using __dpmi_lock_linear_region() and __dpmi_unlock_linear_region().
I hope it helps. DPMI is powerfull, but not very simple :-)
Sincerely,
Eric Nicolas <nicolas AT dsys DOT ceng DOT cea DOT fr>
------
Take a look to the SWORD home page :
france: http://bunny.ensea.fr/Pages_Perso/Cedric_Joulain/sword.web/home.html
us: http://www.iquest.net/~cworley/sword.web/home.html
- Raw text -