🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.language.basm
Article #14

ASM conversion from Delphi to C++Builder

#14
From: Malcolm Smith
Date: Fri, 20 Jul 2007 05:27
35 lines
2160 bytes
I'm trying to convert this PAS code into a C++ unit but I am not having any 
luck with the ASM code - it won't compile as is (although the PAS file 
does).

Can someone please help with the ASM translation.  I know I could just use 
the .PAS file but I want to learn something along the way.


TRegisters = record
  EAX,
  EBX,
  ECX,
  EDX: Cardinal;
end;

procedure GetCPUID(Param: Cardinal; var Registers: TRegisters);
asm
  PUSH    EBX                         {save affected registers}
  PUSH    EDI
  MOV     EDI, Registers
  XOR     EBX, EBX                    {clear EBX register}
  XOR     ECX, ECX                    {clear ECX register}
  XOR     EDX, EDX                    {clear EDX register}
  DB $0F, $A2                         {CPUID opcode}
  MOV     TRegisters(EDI).&EAX, EAX   {save EAX register}
  MOV     TRegisters(EDI).&EBX, EBX   {save EBX register}
  MOV     TRegisters(EDI).&ECX, ECX   {save ECX register}
  MOV     TRegisters(EDI).&EDX, EDX   {save EDX register}
  POP     EDI                         {restore registers}
  POP     EBX
end;


-- 
Malcolm Smith
Technical Details
Message-ID: <46a047d3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 107b11,b95ef5f9173e844a,start
X-Google-Attributes: gid107b11,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Malcolm Smith" <mjfreelancing@optusnet.com.au>
From: "Malcolm Smith" <mjfreelancing@optusnet.com.au>
Newsgroups: borland.public.cppbuilder.language.basm
Subject: ASM conversion from Delphi to C++Builder
Date: Fri, 20 Jul 2007 15:27:22 +1000
Lines: 37
Organization: MJ Freelancing
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 58.107.74.229
Message-ID: <46a047d3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1184909267 58.107.74.229 (19 Jul 2007 22:27:47 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail