базонезависимый код в msvc2008

Discussion in 'LANGS.C' started by GoldFinch, Dec 31, 2008.

  1. GoldFinch

    GoldFinch New Member

    Blog Posts:
    0
    Joined:
    Mar 29, 2008
    Messages:
    1,775
    компилю следующую прогу в msvc2008
    Code (Text):
    1. #pragma comment(linker,"/entry:main")
    2. int x=1;
    3. __declspec(naked) int main()
    4. {
    5.     __asm {
    6.         call base
    7. base:    pop eax
    8.         sub eax,offset base
    9.         mov eax,[eax+offset x]
    10.         ret
    11.     }
    12. }
    вместо mov eax,[eax+offset x] компилится mov eax,offset x

    что делать?
     
  2. Forever

    Forever Виталий

    Blog Posts:
    0
    Joined:
    Apr 12, 2008
    Messages:
    244
    Попробуй отключить оптимизацию что-ли.
     
  3. GoldFinch

    GoldFinch New Member

    Blog Posts:
    0
    Joined:
    Mar 29, 2008
    Messages:
    1,775
    отключил - непомогло, так и так асм вставки не должны оптимизироваться
     
  4. GoldFinch

    GoldFinch New Member

    Blog Posts:
    0
    Joined:
    Mar 29, 2008
    Messages:
    1,775
    эм... оказывается если написать без "offset" то все компилится как надо, т.е.
    mov eax,[eax+offset x] компилится в mov eax,offset x
    а
    mov eax,[eax+x] компилится в mov eax,[eax+offset x]