Thread overview
'this' is always to access to DS: ?
Jun 09, 2001
K.Takaoka
Jun 09, 2001
Walter
Jun 09, 2001
K.Takaoka
Jun 10, 2001
Walter
June 09, 2001
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
June 09, 2001
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


June 09, 2001
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 :)
June 10, 2001
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 :)