www.digitalmars.com         C & C++   DMDScript  

c++.dos.16-bits - 'this' is always to access to DS: ?

reply "K.Takaoka" <takaoka moonlight.gr.jp> writes:
hi, all.

'this' is always NEAR pointer ? (access to DS: ?)

% sc -c -0 -msw test.cpp
% obj2asm test.obj > test.asm

test.cpp:
  class CTest
  {
  public:
    CTest() : v(0) {}
  private:
    int v;
  };

  void main()
  {
    CTest t;
  }

test.asm: _main:
  push  BP
  mov   BP,SP
  sub   SP,2
  lea   AX,-2[BP]    // AX = [ this of t ]
  mov   BX,AX
  mov   [BX],0       // write DS:BX ... illigal !!, want SS:BX
  mov   SP,BP
  pop   BP
  ret
Jun 09 2001
parent reply "Walter" <walter digitalmars.com> writes:
In small memory model, yes. It's best to use far memory models when SS!=DS.
The w modifier is only useful for preventing the optimization in large
memory models that assumes SS==DS.

-Walter

K.Takaoka wrote in message <3B22A2A3.F2042CE4 moonlight.gr.jp>...
hi, all.

'this' is always NEAR pointer ? (access to DS: ?)

% sc -c -0 -msw test.cpp
% obj2asm test.obj > test.asm

test.cpp:
  class CTest
  {
  public:
    CTest() : v(0) {}
  private:
    int v;
  };

  void main()
  {
    CTest t;
  }

test.asm: _main:
  push  BP
  mov   BP,SP
  sub   SP,2
  lea   AX,-2[BP]    // AX = [ this of t ]
  mov   BX,AX
  mov   [BX],0       // write DS:BX ... illigal !!, want SS:BX
  mov   SP,BP
  pop   BP
  ret

Jun 09 2001
parent reply "K.Takaoka" <takaoka moonlight.gr.jp> writes:
thansks,

Walter wrote:
 The w modifier is only useful for preventing the optimization
 in large memory models that assumes SS==DS.

'w' has no effect under small model ? ( and compact model ? ) -- in WonderWitch ( Programming Environment for BANDAI WonderSwan ) CS != DS != SS CS: at FlashROM ... about 384kb DS: at SRAM ... just 64kb SS: at IRAM ... about 2kb CPU: 80186 compatible ... want '-1' 80186 optimize :)
Jun 09 2001
parent "Walter" <walter digitalmars.com> writes:
Not for classes. It will have an effect on things like memcpy().

The 80186 doesn't program any different than the 8088, hence there is no -1.
In fact, it takes a very clever program to even distinguish any difference
at all from a software standpoint (the trick is to do something with
read/write instructions that will highlight a difference between an 8 bit
write and a 16 bit write).

-Walter

K.Takaoka wrote in message <3B22B302.CA242731 moonlight.gr.jp>...
thansks,

Walter wrote:
 The w modifier is only useful for preventing the optimization
 in large memory models that assumes SS==DS.

'w' has no effect under small model ? ( and compact model ? ) -- in WonderWitch ( Programming Environment for BANDAI WonderSwan ) CS != DS != SS CS: at FlashROM ... about 384kb DS: at SRAM ... just 64kb SS: at IRAM ... about 2kb CPU: 80186 compatible ... want '-1' 80186 optimize :)

Jun 09 2001