AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Pascal code to asm

Ein Thema von sniper_w · begonnen am 7. Apr 2006 · letzter Beitrag vom 9. Apr 2006
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von sniper_w
sniper_w

Registriert seit: 11. Dez 2004
Ort: Wien, Österriech
893 Beiträge
 
Delphi 6 Enterprise
 
#1

Pascal code to asm

  Alt 7. Apr 2006, 16:22
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.
Katura Haris
Es (ein gutes Wort) ist wie ein guter Baum, dessen Wurzel fest ist und dessen Zweige in den Himmel reichen.
  Mit Zitat antworten Zitat
Dax
(Gast)

n/a Beiträge
 
#2

Re: Pascal code to asm

  Alt 7. Apr 2006, 16:27
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...
  Mit Zitat antworten Zitat
Benutzerbild von BlackJack
BlackJack

Registriert seit: 2. Jul 2005
Ort: Coesfeld
246 Beiträge
 
Delphi 2005 Personal
 
#3

Re: Pascal code to asm

  Alt 7. Apr 2006, 16:54
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
See my shadow changing, stretching up and over me.
Soften this old armor. Hoping I can clear the way
By stepping through my shadow, coming out the other side.
Step into the shadow. Forty six and two are just ahead of me.
  Mit Zitat antworten Zitat
Dax
(Gast)

n/a Beiträge
 
#4

Re: Pascal code to asm

  Alt 7. Apr 2006, 16:58
Wars nicht EAX, EDX, ECX, Stack?

@edit: ka
  Mit Zitat antworten Zitat
Benutzerbild von BlackJack
BlackJack

Registriert seit: 2. Jul 2005
Ort: Coesfeld
246 Beiträge
 
Delphi 2005 Personal
 
#5

Re: Pascal code to asm

  Alt 7. Apr 2006, 17:00
Zitat von Dax:
Wars nicht EAX, EDX, ECX, Stack?
stimmt hast recht
See my shadow changing, stretching up and over me.
Soften this old armor. Hoping I can clear the way
By stepping through my shadow, coming out the other side.
Step into the shadow. Forty six and two are just ahead of me.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.139 Beiträge
 
Delphi 12 Athens
 
#6

Re: Pascal code to asm

  Alt 7. Apr 2006, 18:29
Code:
shr eax, 3
stimmt auch nicht, da es sich hier um 'nen Integer und keinen LongWord/Cardinal handelt
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Dax
(Gast)

n/a Beiträge
 
#7

Re: Pascal code to asm

  Alt 7. Apr 2006, 18:40
Oh danke, hab doch echt Longword gelesen^^ Wurde in ein SAR verwandelt
  Mit Zitat antworten Zitat
Amateurprofi

Registriert seit: 17. Nov 2005
Ort: Hamburg
1.041 Beiträge
 
Delphi XE2 Professional
 
#8

Re: Pascal code to asm

  Alt 8. Apr 2006, 05:00
[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).
Gruß, Klaus
Die Titanic wurde von Profis gebaut,
die Arche Noah von einem Amateur.
... Und dieser Beitrag vom Amateurprofi....
  Mit Zitat antworten Zitat
Benutzerbild von BlackJack
BlackJack

Registriert seit: 2. Jul 2005
Ort: Coesfeld
246 Beiträge
 
Delphi 2005 Personal
 
#9

Re: Pascal code to asm

  Alt 8. Apr 2006, 12:06
Zitat von himitsu:
Code:
shr eax, 3
stimmt auch nicht, da es sich hier um 'nen Integer und keinen LongWord/Cardinal handelt
dann muss es doch aber auch imul heissen, oder?

@Amateurprofi:
interessant, wusste ich noch gar nicht. aber was sind "dependence-related stalls" ?
See my shadow changing, stretching up and over me.
Soften this old armor. Hoping I can clear the way
By stepping through my shadow, coming out the other side.
Step into the shadow. Forty six and two are just ahead of me.
  Mit Zitat antworten Zitat
Dax
(Gast)

n/a Beiträge
 
#10

Re: Pascal code to asm

  Alt 8. Apr 2006, 12:13
@BlackJack: IMUL ist, soweit ich weiß, signed multiplication

@Amateurprofi: muss ich gleich mal testen

edit: sub ist wirklich schneller
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:30 Uhr.
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