Autor Beitrag
MagicRain
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

WinXp, Win8, iOS
Delphi 7, Lazarus Pascal, Delphi 10.2 Starter, NetBeans Java
BeitragVerfasst: Sa 23.05.09 15:26 
Moin ich habe hier eine Routine wo ich BSWAP brauche ich habe es mit Iinline-Assambler versucht nur leider funktioniert der BSWAP nicht :(

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  EEAX,EEBX,BUFF: DWORD;

      //BSWAP EBX
      asm
        BSWAP EBX
        MOV BUFF,EBX
      end;
      EEBX := BUFF;


Vielleicht weiß ja einer von euch was los ist und hilft mir mal :P Irgendwie bekomme ich bei dem BSWAP ein falsches Resultat heraus :(

MfG


Moderiert von user profile iconAXMD: Topic aus Sonstiges (Delphi) verschoben am So 24.05.2009 um 09:04
dummzeuch
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 593
Erhaltene Danke: 5


Delphi 5 ent, Delphi 6 bis Delphi XE8 pro
BeitragVerfasst: Sa 23.05.09 21:31 
user profile iconMagicRain hat folgendes geschrieben Zum zitierten Posting springen:
Moin ich habe hier eine Routine wo ich BSWAP brauche ich habe es mit Iinline-Assambler versucht nur leider funktioniert der BSWAP nicht :(


Ich bin ja nicht so der Assembler-Spezi, aber macht nicht die Delphi-Funktion Swap genau dasselbe?

twm
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 23.05.09 23:54 
Um es kurz zu machen: Nein, Swap von Delphi und der ASM-Befehl BSWAP machen nicht das Selbe.

Zum Problem:

definiere bitte einmal, aus welcher Variable Du den Wert zu welcher Variable kopiert brauchst?

Ich nehm exemplarisch einmal an, aus Variable A der Wert soll ge-BSWAPed in B landen, dann wäre dies:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
asm
    MOV EAX, DWORD PTR [A]
    BSWAP EAX
    MOV DWORD PTR [B], EAX
end;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Chemiker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 194
Erhaltene Danke: 14

XP, Vista 32 Bit, Vista 64 Bit, Win 7 64 Bit
D7, BDS 2006, RAD Studio 2009+C++, Delphi XE2, XE3, VS 2010 Prof.
BeitragVerfasst: So 24.05.09 00:38 
Hallo MagicRain,

der Inhalt von EBX muss unter Delphi erhalten bleiben. Wenn EBX eingesetzt werden soll, so sollte der Inhalt vorher auf dem Stack gesichert werden und beim Beenden der ASM – Routine wieder hergestellt werden.
So wie Du die ASM – Routine geschrieben hast, kann jeder zufällige Wert dort drin stehen.

Bis bald Chemiker
MagicRain Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154

WinXp, Win8, iOS
Delphi 7, Lazarus Pascal, Delphi 10.2 Starter, NetBeans Java
BeitragVerfasst: So 24.05.09 05:01 
Super danke euch :)

MfG
dummzeuch
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 593
Erhaltene Danke: 5


Delphi 5 ent, Delphi 6 bis Delphi XE8 pro
BeitragVerfasst: So 24.05.09 10:40 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
Um es kurz zu machen: Nein, Swap von Delphi und der ASM-Befehl BSWAP machen nicht das Selbe.


Ja, hast' recht. War wohl zu muede um die Beschreibung zu verstehen. Fuer alle anderen:

* BSWAP (Assembler) konvertiert ein 32 Bit Register von little endian in big endian und umgekehrt: $12345678 -> $78563412
* SWAP (Delphi) vertauscht die beiden Bytes eines 16 Bit Words: $1234 -> $3412

twm