www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/16/18:33:46

Xref: news2.mv.net comp.os.msdos.djgpp:3931
From: nicolas AT dsys DOT ceng DOT cea DOT fr (Eric NICOLAS)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Q: How to handle 64k segments?
Date: 15 May 1996 12:25:53 GMT
Organization: Commissariat a l'energie atomique, Grenoble (France)
Lines: 60
Distribution: world
Message-ID: <4ncigh$qu@news.cea.fr>
References: <19960515131942 DOT herzer AT assi2 DOT fbp DOT fh-weingarten DOT de>
Reply-To: nicolas AT dsys DOT ceng DOT cea DOT fr
NNTP-Posting-Host: hudson.ceng.cea.fr
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019