Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>movedata() copy characters to a different segment</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 movedata()              Copy Characters to a Different Segment

 #include   <mem.h>                      Required for declarations only
 #include   <string.h>                   Use either string.h or memory.h

 void       movedata(srcseg,srcoff,destseg,destoff,nbytes);
 unsigned   srcseg;                      Segment address of source
 unsigned   srcoff;                      Segment offset of source
 unsigned   destseg;                     Segment address of destination
 unsigned   destoff;                     Segment offset of destination
 size_t     nbytes;                      Number of bytes to copy

    movedata() copies 'nbytes' characters from a buffer in one segment to
    a buffer in another.  The source address is 'srcseg:srcoff' and the
    destination address is 'destseg:destoff'.  movedata() is used to move
    far data in tiny, small or medium models where the buffers may be in
    different segments and the segment addresses of data are not
    implicitly known.

       Returns:     Nothing

         Notes:     Segment addresses are implicitly known in large model
                    programs, so you can use memmove() instead of
                    movedata when programming large models.

                    You can obtain segment values for 'srcseg' and
                    'destseg' with either the segread() function or the
                    FP_SEG() macro.

                    movedata() does not always correctly handle
                    overlapping moves (cases in which parts of the
                    destination and source areas share common memory).
                    Overlapping moves are handled correctly by the
                    memmove() function.

   -------------------------------- Example ---------------------------------

    This example moves 1024 bytes of data from the source buffer to the
    destination buffer.

           #include <mem.h>
           #include <dos.h>

           char far *source;
           char far *dest;
           int srce_seg_val;
           int srce_off_val;
           int dest_set_val;
           int dest_off_val;

           main()
           {
               srce_seg_val = FP_SEG(source);
               srce_off_val = FP_OFF(source);
               dest_seg_val = FP_SEG(dest);
               dest_off_val = FP_OFF(dest);
               movedata(srce_seg_val,srce_off_val,dest_seg_val,
                        dest_off_val,1024);
           }


See Also: memcpy() FP_SEG()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson