Date: Tue, 18 Mar 1997 14:18:09 +0300 (IDT) From: Eli Zaretskii To: enigma cc: djgpp AT delorie DOT com Subject: Re: copying from real more to pm... In-Reply-To: <332c7487.7195759@news.erols.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 16 Mar 1997, enigma wrote: > i'm trying to copy memory from a real pointer to a protected mode > pointer. well, i got the copying of bytes to work, but my func for > copying unsigned words isn't working. i could use a little help here > folks Not enough information. The only thing that I can find wrong with your code is that you rely on the FFFFh word to appear before `count' hits 256; if that doesn't happen, you begin to overwrite your memory. However, you didn't tell: 1) How exactly is that code ``not working''. 2) How do you compute the RMptr thing (real-mode pointers are seg:off pairs, so how did you get them into a single UWORD?). Without this info it is hard to know whether your RM_TO_LINEAR macro is correct. Some more notes: > addr = RM_TO_LINEAR((ULONG)RMptr); ^^^^^^^^^^^^ That should be (ULONG)*RMptr I think, no? > _farsetsel(_dos_ds); > while (_farnspeekw(addr) != 0xFFFF) { > buffer[count++] = _farnspeekw(addr++); > addr++; > } Why do you call `_farnspeekw' twice for the same address? Save the value from the first call, then use it inside `while'. > buffer[count] = 0xFFFF; > p = (UWORD *)malloc(count); > memcpy(p,buffer,count); Why do you need to use a local buffer, then move it into another one? Allocate an initial buffer, move directly into it, then grow it or make smaller by calling `realloc'. This is cleaner and doesn't have any artificial limits like 256.