Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Life sucks, but death doesn't put out at all...." -- Thomas J. Kopp


devel / comp.lang.c / Re: borland c 5.0 huge memory model

Re: borland c 5.0 huge memory model

<ue2hps$3dpid$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29116&group=comp.lang.c#29116

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: nos...@please.ty (jak)
Newsgroups: comp.lang.c
Subject: Re: borland c 5.0 huge memory model
Date: Fri, 15 Sep 2023 23:19:54 +0200
Organization: A noiseless patient Spider
Lines: 299
Message-ID: <ue2hps$3dpid$1@dont-email.me>
References: <a13cf161-7c2b-4cd6-bf8a-832919c60308n@googlegroups.com>
<uduml0$2j9c9$1@dont-email.me> <udvbdv$2mfjd$1@dont-email.me>
<FBGMM.1598$8XGa.274@fx17.iad> <udvuus$2q4tc$1@dont-email.me>
<9a54ac27-f1a5-480b-ac8b-f10d5dfe8019n@googlegroups.com>
<ue1pqr$39ir2$1@dont-email.me>
<486c0f8b-7404-4ccf-baa4-f623224eb7ccn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 15 Sep 2023 21:19:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="80826f211054e296601c60f39f23f2b0";
logging-data="3597901"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Q73tnjldsMWzVIv66rvQx"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17
Cancel-Lock: sha1:Av1uhcOWr5yVs+M4hNit8bCBeGs=
In-Reply-To: <486c0f8b-7404-4ccf-baa4-f623224eb7ccn@googlegroups.com>
 by: jak - Fri, 15 Sep 2023 21:19 UTC

Paul Edwards ha scritto:
> On Friday, September 15, 2023 at 10:31:08 PM UTC+8, jak wrote:
>> Paul Edwards ha scritto:
>>> On Friday, September 15, 2023 at 12:33:56 AM UTC+8, Richard Damon wrote:
>>>
>>>> On 9/14/23 9:12 AM, jak wrote:
>>>>> jak ha scritto:
>>>
>>> Hi both.
>>>
>>> Thanks for your replies.
>>>
>>>> There was no model that defaulted pointers to "Huge", likely because
>>>> Huge pointers were inefficient and a program that needed this would only
>>>> need it in a few places.
>>>
>>> It's easier to simply demonstrate with generated code
>>> from what I currently have installed. Note that the reason
>>> I want a decent huge memory model is because:
>>>
>>> 1. I want to address SOME data that is more than 64k
>>> 2. I don't what to pollute my C90 code with a non-standard
>>> "huge" keyword in the various places that need it.
>>> 3. I don't want to find the various places that may need it.
>>> 4. Real world testing by someone who actually did real
>>> world testing reported that huge memory model gives a
>>> 4% overhead, not 4000% like everyone seems to believe.
>>> 5. I don't even care if it is a 100% overhead. Someone who
>>> cares can pollute the provided source code with
>>> non-standard keywords and/or rewrite in assembler
>>> and/or simply upgrade to a faster processor.
>>>
>>>
>>> D:\scratch\zzz>type foo.c
>>> char huge *foo(char huge *a)
>>> {
>>> return a + 5;
>>> }
>>>
>>> D:\scratch\zzz>bcc -mh -S foo.c
>>> Borland C++ 5.0 Copyright (c) 1987, 1996 Borland International
>>> foo.c:
>>>
>>> D:\scratch\zzz>
>>>
>>>
>>> ;
>>> ; char huge *foo(char huge *a)
>>> ;
>>> push bp
>>> mov bp,sp
>>> push ds
>>> mov ax,FOO_DATA
>>> mov ds,ax
>>> ;
>>> ; {
>>> ; return a + 5;
>>> ;
>>> mov dx,word ptr [bp+8]
>>> mov ax,word ptr [bp+6]
>>> xor cx,cx
>>> mov bx,5
>>> call far ptr F_PADD@
>>> ;
>>> ; }
>>> ;
>>> pop ds
>>> pop bp
>>> ret
>>>
>>>
>>>
>>>
>>> D:\scratch\zzz>type foo.c
>>> char *foo(char *a)
>>> {
>>> return a + 5;
>>> }
>>>
>>> D:\scratch\zzz>bcc -mh -S foo.c
>>> Borland C++ 5.0 Copyright (c) 1987, 1996 Borland International
>>> foo.c:
>>>
>>> D:\scratch\zzz>
>>>
>>>
>>> ; char *foo(char *a)
>>> ;
>>> push bp
>>> mov bp,sp
>>> ;
>>> ; {
>>> ; return a + 5;
>>> ;
>>> mov dx,word ptr [bp+8]
>>> mov ax,word ptr [bp+6]
>>> add ax,5
>>> ;
>>> ; }
>>> ;
>>> pop bp
>>> ret
>>>
>>>
>>>
>>> D:\scratch\zzz>\msvc15\bin\cl -S -AH -Ox foo.c
>>> Microsoft (R) C/C++ Optimizing Compiler Version 8.00c
>>> Copyright (c) Microsoft Corp 1984-1993. All rights reserved.
>>>
>>> foo.c
>>>
>>> D:\scratch\zzz>
>>>
>>>
>>> _foo PROC FAR
>>> ; Line 2
>>> push bp
>>> mov bp,sp
>>> ; a = 6
>>> ; Line 3
>>> mov ax,WORD PTR [bp+6] ;a
>>> mov dx,WORD PTR [bp+8]
>>> add ax,5
>>> sbb cx,cx
>>> and cx,OFFSET __AHINCR
>>> add dx,cx
>>> ; Line 4
>>> pop bp
>>> ret
>>>
>>>
>>>
>>> D:\scratch\zzz>wcl -mh -c foo.c
>>> Open Watcom C/C++16 Compile and Link Utility Version 1.6
>>> Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
>>> Source code is available under the Sybase Open Watcom Public License.
>>> See http://www.openwatcom.org/ for details.
>>> wcc foo.c -mh
>>> Open Watcom C16 Optimizing Compiler Version 1.6
>>> Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
>>> Source code is available under the Sybase Open Watcom Public License.
>>> See http://www.openwatcom.org/ for details.
>>> foo.c: 4 lines, 0 warnings, 0 errors
>>> Code size: 25
>>>
>>> D:\scratch\zzz>
>>>
>>>
>>> D:\scratch\zzz>wdis foo.obj
>>> Module: D:\scratch\zzz\foo.c
>>> GROUP: 'DGROUP' CONST,CONST2,_DATA
>>>
>>> Segment: foo_TEXT BYTE USE16 00000019 bytes
>>> 0000 foo_:
>>> 0000 50 push ax
>>> 0001 B8 08 00 mov ax,0x0008
>>> 0004 9A 00 00 00 00 call __STK
>>> 0009 58 pop ax
>>> 000A 53 push bx
>>> 000B 51 push cx
>>> 000C BB 05 00 mov bx,0x0005
>>> 000F 31 C9 xor cx,cx
>>> 0011 9A 00 00 00 00 call __PIA
>>> 0016 59 pop cx
>>> 0017 5B pop bx
>>> 0018 CB retf
>>>
>>>
>>> So - Microsoft has a variable fit for purpose, and Watcom has
>>> a function call fit for purpose.
>>>
>>> Borland has a function call fit for purpose only if you add
>>> the "huge" keyword to every pointer declaration.
>>>
>>> BFN. Paul.
>>>
>> mmmh ... there is something that does not convince me but unfortunately
>> I don't have an environment to perform a test. Could you do it for me?
>> I do not convince me that both functions the one with Huge in the
>> declaration of the function and the one without ending with 'ret' while
>> the one with Huge should end with 'retf'.
>
> This is normal - I didn't show the full assembler.
>
> _foo PROC FAR
>
> or
>
> .model huge etc
>
> in the assembler will convert a ret to retf automatically (in a proc).
>
>> Could you recompile with BCC
>> completely disabling the optimizer?
>> (Forgive my request)
>
> I didn't use the optimizer with bcc. ie if you look at the
> command line above, I don't have a "-O-anything".
>
> BFN. Paul.
>
>
>
> D:\scratch\zzz>bcc
> Borland C++ 5.0 Copyright (c) 1987, 1996 Borland International
> Syntax is: BCC [ options ] file[s] * = default; -x- = turn switch x off
> -1 80186/286 Instructions -2 * 80286 Protected Mode Inst.
> -3 80386 Instructions -Ax Disable extensions
> -B Compile via assembly -C Allow nested comments
> -Dxxx Define macro -Exxx Alternate Assembler name
> -Hxxx Use pre-compiled headers -Ixxx Include files directory
> -K Default char is unsigned -Lxxx Libraries directory
> -M Generate link map -N Check stack overflow
> -Ox Optimizations -P Force C++ compile
> -R Produce browser info -RT * Generate RTTI
> -S Produce assembly output -Txxx Set assembler option
> -Uxxx Undefine macro -Vx Virtual table control
> -X Suppress autodep. output -Yx Overlay control
> -Z Suppress register reloads -aN Align on N bytes
> -b * Treat enums as integers -c Compile only
> -d Merge duplicate strings -exxx Executable file name
> -fxx Floating point options -gN Stop after N warnings
> -iN Max. identifier length -jN Stop after N errors
> -k * Standard stack frame -lx Set linker option
> -mx Set Memory Model -nxxx Output file directory
> -oxxx Object file name -p Pascal calls
> -po fastthis calls -tWxxx Create Windows app
> -u * Underscores on externs -v Source level debugging
> -wxxx Warning control -xxxx Exception handling
> -y Produce line number info -zxxx Set segment names
>
> D:\scratch\zzz>
>
The option to disable optimizations should be '-Od'. Below I am
attaching the list of optimization flags that should be available in
your compiler:

-02 Options - Compiler - Optimizations - Full Speed
-Ox Generates the fastest code possible. This is the same as using the
following
command-line options: -0 -Ob -Oe -Og -Oi -Ol-Om -Op -Ot -Ov -k- -Z
-01 Options - Compiler - Optimizations - Full Size
Generates the smallest code possible. This is the same as using the
following
command-line options: -0 -Ob -Oe -Ol-Os -k- -Z
-0 Options - Compiler - Optimizations - Optimize Jumps
Removes jumps to jumps, unreachable code, and unnecessary jumps
-Oa Options - Compiler - Optimizations - Assume no pointer aliasing
Assume that pointer expressions are not aliased in common subexpression
evaluation
-Ob Options - Compiler - Optimizations - Dead code elimination
Eliminates stores into dead variables and conditional expressions
whose values
can be determined at compiletime
-Oc Options - Compiler - Optimizations - Common Subexpressions -
Optimize locally
Enables common sub expression elimination within basic blocks only.
The -Oc
option and the -Og option are mutually exclusive
-Od Options - Compiler - Optimizations - No Optimizing
Disables all optimizations. Note that this is not the same as -0-,
which merely
disables jump optimizations. It is equivalent to -O-cgbelmvpi -Z-
-0-. Also
note that this option doesn't change the code-generation options
for size (-Os)
or speed (-0).
-Oe Options - Compiler - Optimizations - Global register allocation
Enables global register allocation and variable live range analysis
-Og Options - Compiler - Optimizations - Common Sub expressions -
Optimize globally
Enables common sub expression elimination within an entire
function. The -Og
option and the -Oc option are mutually exclusive
-Oi Options - Compiler - Optimizations - Inline intrinsics
Enables inlining of intrinsic functions such as memcpy, strlen, etc.
-01 Options - Compiler - Optimizations - Loop optimization
Compacts loops into REP /STOSx instructions
-Om Options - Compiler - Optimizations - Invariant code motion
Moves invariant code out of loops
-Op Options - Compiler - Optimizations - Copy propagation
Propagates copies of constants, variables, and expressions where
possible
-Os Options - Compiler - Optimizations - Optimize for - Size
Makes code-selection choices in favor of smaller code
-Ot Options - Compiler - Optimizations - Optimize for - Speed
Selects code in favor of executable speed
-Ov Options - Compiler - Optimizations - Induction Variables
Enables loop-induction variable and strength-reduction optimizations
-Z Options - Compiler - Optimizations - Suppress redundant loads
Suppresses reloads of values which are already in registers
-po Options - Compiler - Optimizations - Object Data Calling
Enables the use of the Object Data calling convention for passing
this in a
register to member functions.
-pr Options - Compiler - Entry /Exit Code - Calling Convention - Register
Enables the use of the _fastcall calling convention for passing
parameters in
registers

SubjectRepliesAuthor
o borland c 5.0 huge memory model

By: Paul Edwards on Thu, 14 Sep 2023

17Paul Edwards
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor