www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/08/07/03:16:03

To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: movedata vs dosmemput
Date: Sun, 07 Aug 94 09:18:36 +0300
From: eliz AT is DOT elta DOT co DOT il

movedata() and dosmemxxx() should do the same thing, but
movedata() seems not always to work.  The following short
program illustrates this.  Under DPMI, it GP faults when
movedata() is used, but works ok if dosmemput() is used
instead.  (When invoked with GO32=nodpmi, it doesn't bomb,
but prints garbage instead of argv[0].)

-------------- file movd_tst.c -------------------
#include <stdio.h>
#include <stdlib.h>
#include <dpmi.h>
#include <go32.h>

void main(int argc, char *argv[])
{
  char progname[128];

#ifdef MOVEDATA
  movedata(_go32_my_ds(), (u_int)argv[0], _go32_conventional_mem_selector(),
           _go32_info_block.linear_address_of_transfer_buffer,
           strlen(argv[0]) + 1);
#else
  dosmemput(argv[0], strlen(argv[0]) + 1,
            _go32_info_block.linear_address_of_transfer_buffer);
#endif

  dosmemget(_go32_info_block.linear_address_of_transfer_buffer,
            strlen(argv[0]) + 1, progname);

  printf("Copy: %s\n", progname);

  exit(0);
}

-----------------------------------------------------

What's the reason for that?  I want to use movedata() because
it's faster: it moves 32-bit words instead of bytes (my actual
program moves more than a few bytes to conventional memory, so
it could be a win).

What am I doing wrong?  Can anybody help me?

	Eli Zaretskii

- Raw text -


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