Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7555689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:40:24+00:00 2026-05-30T11:40:24+00:00

please i’ve this GCC inline assembler piece of code int src = 0; dword

  • 0

please i’ve this GCC inline assembler piece of code

int   src = 0;
dword n;
__asm(
            "sar %%cl,%%edx"
            : "=d" (n) // saves in eax,edx
            : "c" (src), "d" (n) // the inputs
            );

and my delphi attempt is :

asm
mov ecx, &src
mov edx, &n
sar cl,edx
mov eax,edx
end;

please is that correct ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:40:26+00:00Added an answer on May 30, 2026 at 11:40 am

    Inline assembler does not work the same way in Delphi as it does in GCC. For starters, you don’t have the same kind of macro and template support in Delphi, so if you want to use a declare-once general purpose assembler routine, you have to declare it as a function:

    function ShiftArithmeticRight(aShift: Byte; aValue: LongInt): LongInt;
    {$IFDEF WIN64}
    asm
      sar edx,cl
      mov eax,edx
    end;
    {$ELSE}
    {$IFDEF CPU386}
    asm
      mov cl,al
      sar edx,cl
      mov eax,edx
    end;
    {$ELSE}
    begin
      if aValue < 0 then
        Result := not (not aValue shr aShift)
      else
        Result := aValue shr aShift;
    end;
    {$ENDIF}
    {$ENDIF}
    

    In Delphi, inline assembler has to be implemented at the spot where it is used, and it is only supported in 32-bit. In such asm blocks you can use the EAX,ECX,EDX freely, plus any identifiers in the surrounding code. For instance:

    var
      lValue: LongInt;
      lShift: Byte;
    begin
      // Enter pascal code here
      asm
        mov cl,lShift
        sar lValue,cl
      end;
      // Enter pascal code here
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please have a look at the following code: <HTML> <HEAD> <script src=//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js type=text/javascript></script> <SCRIPT
Please, help me. I dont know what is wrong with this code: import android.appwidget.AppWidgetProvider;
Please look at this code: @interface myObject:NSObject -(void)function:(id)param; @end @implementation myObject -(void)function:(id)param { NSLog(@BEFORE);
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
Please, provide code examples in a language of your choice. Update : No constraints
Please consider this Query: SELECT tesd.State_Code, tesd.City_Code, tesd.Row_ID, tesd.Qsno, tesd.Total_Period, tesd.Current_Period, tesd.Week, tesd.Block_No, tesd.Family_ID,
Please consider the following code: #include <iostream> #include <typeinfo> template< typename Type > void
Please Help me to do this first i have this div <div class=loader alt=stat.php>
Please tell me why i am getting ClassCastException in this case I have type
Please correct me if I am wrong. I am asking this question to clarify

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.