#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0

    Question Can anyone tell me what does this code mean?


    {$DEFINE ASM_MODE}
    program Calculator;

    {$APPTYPE CONSOLE}

    {$R *.res}

    {$IFDEF PLAIN_LANGUAGE}
    Function MultiplyByTwo (a:cardinal) : cardinal;
    begin
    result:=a * 2;
    end;
    {$ENDIF}

    {$IFDEF ASM_MODE}
    Function MultiplyByTwo (a:cardinal):cardinal; assembler;
    asm
    mov ESI, 2
    mul EDX;
    end;
    {$ENDIF}

    var
    mula,c: cardinal;

    begin
    c:=2;
    mula:=MultiplyByTwo(c);
    end.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Posts
    2
    Rep Power
    0
    no ne can answer here plz
    i don't know about this code what for this, please tell me please
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2006
    Location
    Carlsbad, CA
    Posts
    2,055
    Rep Power
    383
    You need to look up the purpose of an $IFDEF statement.
    Once you do, all will be clear.

    However, there is a potential problem with the code as it does not ensure that only
    one of the two defines can be defined at the same time.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    35
    Rep Power
    2
    What does your code do?
    It defines zero, one or two versions of "MultiplyByTwo".
    One is written in Assembler, the other one in Delphi, and both do the same thing, namely multiply a number by 2.

    ___________
    Visit my project: Online symbolic derivative calculator

IMN logo majestic logo threadwatch logo seochat tools logo