Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Pascal code to asm (https://www.delphipraxis.net/66999-pascal-code-asm.html)

sniper_w 7. Apr 2006 16:22


Pascal code to asm
 
Ich habe folgende Funktion in pascal:
Delphi-Quellcode:
function func( PPS, BPP, A: Longint): Longint;
begin
  Dec(A);
  Result := ((PPS * BPP) + A) and not A;
  Result := Result div 8;
end;
Ich kann kein asm :(. Wenn jemand Zeit finden würde, diese Funktion nach asm zu übersetzen, wäre ich dankbar.

Ich selber mag dieser Art der Fragestellung nicht, und ich verstehe es, wenn sorag diesen Thread geschlossen wäre, aber ich bin im Not.
Danke.

Dax 7. Apr 2006 16:27

Re: Pascal code to asm
 
Du musst das garnicht übersetzen, lass es doch Delphi für dich machen ;) Einfach nen Breakpoint auf das begin setzen, F9, wenns am Breakpoint angekommen ist Strg+Alt+C und das was dann da steht abschreiben :)

Edit: ohne es zu testen würd ich tippen das es mit
Delphi-Quellcode:
function func( PPS, BPP, A: Longint): Longint;
asm
  sub ecx, 1
  mul edx
  add eax, acx
  not ecx
  and eax, ecx
  sar eax, 3
end;
funktionieren sollte...

BlackJack 7. Apr 2006 16:54

Re: Pascal code to asm
 
die Parameter sollten doch so übergeben werden, oder?
EAX = PPS
ECX = BBP
EDX = A

dann muss ganz am anfang von Dax code noch ein
Code:
xchg edx, ecx
rein und es sollte passen. (und noch aus acx ecx machen ;) )

edit:
ich hab mir gerade mal den ASM-Code angeschaut, den der Delphi-Compiler daraus macht. Wieso macht der denn da so sachen wiw z.b.
Code:
Sub ecx, 1
statt einfach
Code:
dec ecx
:gruebel:

Dax 7. Apr 2006 16:58

Re: Pascal code to asm
 
Wars nicht EAX, EDX, ECX, Stack? :gruebel:

@edit: ka :lol:

BlackJack 7. Apr 2006 17:00

Re: Pascal code to asm
 
Zitat:

Zitat von Dax
Wars nicht EAX, EDX, ECX, Stack? :gruebel:

stimmt hast recht :thumb:

himitsu 7. Apr 2006 18:29

Re: Pascal code to asm
 
Code:
shr eax, 3
stimmt auch nicht, da es sich hier um 'nen Integer und keinen LongWord/Cardinal handelt :zwinker:

Dax 7. Apr 2006 18:40

Re: Pascal code to asm
 
Oh danke, hab doch echt Longword gelesen^^ Wurde in ein SAR verwandelt :)

Amateurprofi 8. Apr 2006 05:00

Re: Pascal code to asm
 
[quote="BlackJack"]
edit:
ich hab mir gerade mal den ASM-Code angeschaut, den der Delphi-Compiler daraus macht. Wieso macht der denn da so sachen wiw z.b.
Code:
Sub ecx, 1
statt einfach
Code:
dec ecx
:gruebel

Weil SUB ECX,1 schneller ist.

Aus Intels Optimization Guidelines:
Avoid instructions that unnecessarily introduce dependence-related
stalls: inc and dec instructions, partial register operations (8/16-bit
operands).

BlackJack 8. Apr 2006 12:06

Re: Pascal code to asm
 
Zitat:

Zitat von himitsu
Code:
shr eax, 3
stimmt auch nicht, da es sich hier um 'nen Integer und keinen LongWord/Cardinal handelt :zwinker:

dann muss es doch aber auch imul heissen, oder?

@Amateurprofi:
interessant, wusste ich noch gar nicht. aber was sind "dependence-related stalls" ?

Dax 8. Apr 2006 12:13

Re: Pascal code to asm
 
@BlackJack: IMUL ist, soweit ich weiß, signed multiplication

@Amateurprofi: muss ich gleich mal testen :)

edit: sub ist wirklich schneller :shock:


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:19 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz