Date: Thu, 18 Mar 93 10:28:55 JST From: Makoto Kobayashi To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: DPMI & new GO32 References: <9303171317 DOT AA00683 AT delorie DOT ctron> <9303171535 DOT AA04672 AT DG1 DOT CHEMIE DOT UNI-KONSTANZ DOT DE> "go32.com" in ftp.sigmath.osaka-u.ac.jp can work with various restrictions and some modifications under DPMI. It does not supports graphics, emu387, stack is limited to 1 mega bytes, etc. DPMI 0.9 does *NOT* support demand-loading mechanism. For i386 demand-paged executable the SEGMENT_SIZE is fixed to 0x400000 bytes, and then DATA must be started after 0x400000. This is because a.out requires incomprehensibly large memory size running in windows environment. Of cource the stack must be located in another segment and you must not use -foimit-frame-pointer optimizing option because the default segment of BP is SS. I found that go32 supports COFF header (0x14c) and this header has an information of SEGMENT_SIZE in it. I added the two line in ld.c : #define COFF_ENCAPSULATE #define SEGMENT_SIZE page_size and recompiled it. This time the linker creates a nice a.out which requires less memory than before. ( e.g. 10 mega bytes to 2 mega bytes for same source file) Other points to run a.out in windows: 1. New fashion read/write cannot be used. Only old style read.s and write.s can do. 2. sbrk() returens uninitialized memory and malloc occurs trouble. A patch to solve this problem is follows. *** paging.c Tue Nov 10 01:57:36 1992 --- c:paging.c Wed Mar 10 16:36:34 1993 *************** *** 813,819 **** --- 813,822 ---- int changeBreak(word32 breakPoint) { + word32 oldbytes; word32 newBytes = (breakPoint + 0xfff) & ~0xfff; + oldbytes=myMemory.bytes; + if (oldbytes < areas[3].first_addr) oldbytes=areas[3].first_addr; if (myMemory.bytes != newBytes) { DPMIprotectedMode(); if (! DPMIrealloc(&myMemory, newBytes)) { *************** *** 826,831 **** --- 829,838 ---- (areas[A_stack].first_addr - 1) >> 12); DPMIrealMode(); } + + if(newBytes > oldbytes) + Pmemset(mySelector, oldbytes, 0, newBytes - oldbytes ); + areas[3].last_addr = breakPoint - 1; return 1; } /* read.s */ .text .globl _read _read: pushl %ebx pushl %esi pushl %edi movl 16(%esp),%ebx movl 20(%esp),%edx movl 24(%esp),%ecx movb $0x3f,%ah int $0x21 error: popl %edi popl %esi popl %ebx jb syscall_error ret /* write.s */ .text .globl _write _write: pushl %ebx pushl %esi pushl %edi movl 16(%esp),%ebx movl 20(%esp),%edx movl 24(%esp),%ecx cmpl $4096,%ecx movb $0x40,%ah int $0x21 popl %edi popl %esi popl %ebx jb syscall_error ret Faculty of Eng., Mi'e Univ., Tsu, Japan. na70103 AT cc DOT mie-u DOT ac DOT jp Makoto Kobayashi