Date: Mon, 27 Apr 1998 15:25:08 +0200 (CEST) From: Archee/CoNTRACT <01dsolt AT Vpg17 DOT vpg DOT hu> To: Aurelio cc: djgpp AT delorie DOT com Subject: Re: A strange memory problem In-Reply-To: <01bd7094$1de72440$78001dc2@rigotti> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk hi ! It is not strange. You have to put $16000 in %ecx, not %cx. you have to save %es by pushing it. I do it in the following way: short screenselector; <- have to be GLOBAL (ds) void proc { screenselector=__dpmi_createselector(1); // I cannot remember exactly of the procedures name. __dpmi_set_selector_base(screenselector,0xa0000); __dpmi_set_selector_limit(screenselector,320*200); __asm__ (" pushw %es movw _screenselector,%es cld xorl %edi,%edi movl _framebuffer,%esi movl $16000,%ecx rep MOVSL /* MOVSL uses ES for DEST and DS for src */ popw %es "); My way works under win95 and DOS fine. BUT the bigger problame: You can use 16bit and 32 bit/pixel using VBE 1.2 or VBE 2.0 I think you have to write it for VBE 1.2 and VBE 2.0 to. I have an engine for that. (supporting VBE 2.0 and 1.2 too, and convert the picture to 16bit/pixel if the user dont have 32 bit/pixel.....) I can send it to ya. Just mail me at soltesz AT hotmail DOT com -- Archee/CoNTRACT CODER ( 01dsolt AT vpg DOT hu ) oldnikk:stonee,sutyi web: http://gondolat.vpg.hu/~01dsolt On 25 Apr 1998, Aurelio wrote: > I have a very strange problem with DJGPP. I'm using DJGPP under WIN95 > with the gcc compiler. I wrote this code: > > int main() > { > Set_Video_Mode(0x13); > > BYTE * DoubleBuffer = (BYTE *) calloc(64000,1); > > BYTE * test = (BYTE *)malloc(10); > free(test); > > //copy of DoubleBuffer in video memory > __asm__ __volatile__(" \n > cld \n > movw $16000,%%cx \n > movw %1,%%es \n > movl $0xA0000,%%edi \n > movl %0,%%esi \n > rep \n > movsl " > : > :"S"(DoubleBuffer),"g"(_dos_ds) > :"edi","cx","ebx","memory" > ); > > free(DoubleBuffer); > > return 0; > } > > When I execute this code the program crashes with the error: > General protection fault etc.. > > If I delete the 2 lines that allocate the 10 bytes > BYTE * test = (BYTE *)malloc(10); > free(test); > > the program doesn't crash. > > Someone can help? > >