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 6567539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:20:57+00:00 2026-05-25T14:20:57+00:00

I am trying to convert a C code to Delphi/pascal, but somehow I cannot

  • 0

I am trying to convert a C code to Delphi/pascal, but somehow I cannot get it to work, my approach was like this :

function CheckLRC(s : PChar) : Char;
var
  sum : char;
begin
  sum := #0;
  while (^s <> #0) do
  begin
    sum := (sum XOR ^s);
    inc (s)
  end;
  result := sum;
end;

Original C code was :

   Set LRC = 0
   For each byte b in the buffer
   do
     Set LRC = (LRC + b) AND 0xFF
   end do
   Set LRC = (((LRC XOR 0xFF) + 1) AND 0xFF)

Hope anyone out there is able to help me, and can confirm this is the correct way to do an LRC checksum ?

  • 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-25T14:20:57+00:00Added an answer on May 25, 2026 at 2:20 pm

    I guess the exact equivalence of this function may be:

    function CheckLRC(const s: AnsiString): byte;
    var i: integer;
    begin
      result := 0;
      for i := 1 to length(s) do
        inc(result,ord(s[i]));
      result := (result xor $FF)+1; // or result := (not result)+1;
    end;
    

    All “and $FF” in original code is unneeded here, since we are using a byte as result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the Delphi code I'm trying to convert to .net: s1 := Copy
I'm trying to convert this Python code to C. But for the life of
I'm trying to convert this code fragment into Delphi and I got stuck on
I'm trying to convert some code that worked great in VB, but I can't
Trying to convert this c code into MIPS and run it in SPIM. int
I'm trying to convert a character code to a character with chr(), but VBScript
I am trying to convert this test code to C# and having a problem
Im trying to convert some Delphi code to c# and I've come across a
I'm trying to convert some code from Javascript to c. The function creates an
I am trying to convert VB6 code to c# and I ran into this

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.