Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft 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   <memory.h>                   Required for declarations only
 #include   <string.h>                   Use either string.h or memory.h

 void       movedata(srcseg,srcoff,destseg,destoff,nbytes);
 int        srcseg;                      Segment address of source
 int        srcoff;                      Segment offset of source
 int        destseg;                     Ssegment address of destination
 int        destoff;                     Segment offset of destination
 unsigned   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 small or medium models where the buffers may be in
    different segments and the segment addresses of data are not
    implicitly known.

    Returns:    There is no return value.

      Notes:    Since segment addresses are implicitly known in large
                model programs, you can use memcpy() 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 handle overlapping moves
                correctly (i.e., a case in which part of the destination
                area and source area share common memory).  Overlapping
                moves are handled correctly by the memcpy() function.

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

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

         #include <memory.h>
         #include <dos.h>

         char far *source;
         char far *dest;
         unsigned int srce_seg_val;
         unsigned int srce_off_val;
         unsigned int dest_set_val;
         unsigned 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() segread() FP_SEG()

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