From: enigma AT erols DOT com (enigma) Newsgroups: comp.os.msdos.djgpp Subject: Re: copying from real more to pm... Date: Tue, 18 Mar 1997 23:12:39 GMT Organization: djgpp, i luv u ;) Lines: 50 Message-ID: <332f1f9a.123813@news.erols.com> References: <332c7487 DOT 7195759 AT news DOT erols DOT com> NNTP-Posting-Host: dam-as9s40.erols.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On Sun, 16 Mar 1997 22:36:24 GMT, enigma AT erols DOT com (enigma) wrote: >ok.. this has been bugging me for a little why... >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 > >code: > >#define RM_TO_LINEAR(addr) (((addr & 0xFFFF0000) >> 12) + (addr & >0xFFFF)) > >UWORD *PMcopyWordtoLocal(UWORD *RMptr) { > > UWORD buffer[256], *p; > UWORD count = 0; > ULONG addr; > > addr = RM_TO_LINEAR((ULONG)RMptr); > _farsetsel(_dos_ds); > while (_farnspeekw(addr) != 0xFFFF) { > buffer[count++] = _farnspeekw(addr++); > addr++; > } > buffer[count] = 0xFFFF; > p = (UWORD *)malloc(count); > memcpy(p,buffer,count); > return p; > >} > >feel free to criticize my code as much as necessary. style, >bugs,etc.. >just gimme my mistake ;) oops ok.. i guess i was a bit cryptic.. ok this basically is used to grab an array that the vesa bios returns after a function call. what it should be doing is copying UWORD's (defined as unsigned int) <-- is this wrong? should they be defined as unsigned short's? the array is terminated by a word filled with 0xFFFF. what the code above does is give me back is just worthless numbers (should be video mode numbers). i am looking into Eli's suggestions, but with the added info, can anyone see an obivous error? mint enigma AT erols DOT com djgpp is an obsession