copy bytes from one far pointer to another
#include <string.h> void movedata( unsigned int src_segment, unsigned int src_offset, unsigned int tgt_segment, unsigned int tgt_offset, size_t length );
The movedata() function copies length bytes from the far pointer calculated as (src_segment:src_offset) to a target location determined as a far pointer (tgt_segment:tgt_offset).
Overlapping data may not be correctly copied. When the source and target areas may overlap, copy the areas one character at a time. |
The function is useful to move data when the near address(es) of the source and/or target areas aren't known.
#include <sys/mman.h> main() { char buffer[14] = { H, 0x17, e, 0x17, l, 0x17, l, 0x17, o, 0x17 }; int fd,len; int addr = 0xb8000; char *p; if ((fd=shm_open( "Physical", O_RDWR, 0)) == -1) { fprintf( stderr, "cannot access physical (%s)\n", strerror(errno)); } len = sizeof( buffer ); if ((p=mmap( 0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, addr)) == -1) { fprintf( stderr, "cannot map video screen (%s)\n", strerror(errno)); } movedata( FP_SEG( buffer ), FP_OFF( buffer ), FP_SEG( p ), FP_OFF( p ), 14 ); }
WATCOM
Safety: | |
---|---|
Interrupt handler | Yes |
Signal handler | Yes |
Thread | Yes |
FP_SEG(), FP_OFF(), memcpy(), segread()