Date: Mon, 22 Dec 1997 10:17:04 +0200 (IST) From: Eli Zaretskii To: Dave Nugent cc: djgpp AT delorie DOT com Subject: Re: How to use _movedatal In-Reply-To: <349D2ED7.D04@ns.sympatico.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Sun, 21 Dec 1997, Dave Nugent wrote: > Hi, I'm a newbie at DJGPP, and am trying to figure out how to use > _movedatal > to move 32 bits at a time from one array to another. Wrong function. Use `memcpy' instead. Not only is it simpler (no segments), it is also ANSI C, so your program will be more portable to other compilers. > The syntax I have shows _movedata(unsigned, unsigned, unsigned, > unsigned, size_t) > > unsigned, unsigned, unsigned, unsigned WHAT????? There's a cross-reference on that page which you were supposed to follow. It leads to the `movedata' page which explains all the arguments. > I kinda thought like unsigned src seg, unsigned src offset, unsigned > dest seg, unsigned dest offset, but isn't DJGPP supposd to work > without these segment headaches? `_movedatal' is for moving data to/from portions of memory that aren't mapped into your address space, like your SVGA's video RAM, or the conventional memory used by DOS. Thus you need to use a different segment to reach them without generating a protection violation and crashing your program. (And btw, memory segmentation is a (mis)feature of the Intel architecture, it doesn't go away when you switch to protected mode.) > I would appreciate an example on how to use this. I have a large array > set up as follows: > > long unsigned storage[1000000]; > long unsigned current[20000]; > > I want to be able to copy 20000 bytes from storage to current.. The > program will determine where to start copying from in array storage. How about this: #include ... memcpy (current, storage + offset, 20000);