AGB  ·  Datenschutz  ·  Impressum  







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

Simple asm from x86 to x64

Ein Thema von WojTec · begonnen am 11. Apr 2017 · letzter Beitrag vom 12. Apr 2017
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Simple asm from x86 to x64

  Alt 11. Apr 2017, 17:56
Could you make for me compatible with both 32/64 bits this asm code (now is x86 only), because I'm not familiar with Assembler

Delphi-Quellcode:
procedure ByteToHex(const AValue: Byte; Buffer: PAnsiChar);
asm
  JMP @@Convert
  @@HexTable:
    DB '0123456789ABCDEF';
  @@Convert:
    PUSH ECX // Invalid combination of opcode and operands
    XOR ECX, ECX
    MOV CL, AL
    SHR CL, 4
    MOV CL, @@HexTable.Byte[ECX] // Assembler instruction requires a 32bit absolute address fixup which is invalid for 64bit
    MOV BYTE PTR [EDX], CL
    MOV CL, AL
    AND CL, 0Fh
    MOV CL, @@HexTable.Byte[ECX] // Above error also here
    MOV BYTE PTR [EDX+1], CL
    POP ECX
end;
  Mit Zitat antworten Zitat
Fritzew

Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Simple asm from x86 to x64

  Alt 11. Apr 2017, 18:10
warum Assembler?
hast Du nicht genug mit Delphi und C++ zu tun


sysutils : IntToHex
Fritz Westermann
  Mit Zitat antworten Zitat
jbg

Registriert seit: 12. Jun 2002
3.483 Beiträge
 
Delphi 10.1 Berlin Professional
 
#3

AW: Simple asm from x86 to x64

  Alt 11. Apr 2017, 18:25
You could try this code. It is even slightly faster than your assembler code if you activate the compiler's code optimization.

Delphi-Quellcode:
procedure ByteToHex(const AValue: Byte; Buffer: PAnsiChar);
const
  HexChars: array[0..15] of AnsiChar = '0123456789ABCDEF';
begin
  Buffer[0] := HexChars[AValue shr 4];
  Buffer[1] := HexChars[AValue and $F];
end;

Geändert von jbg (12. Apr 2017 um 11:04 Uhr)
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#4

Re: Simple asm from x86 to x64

  Alt 11. Apr 2017, 19:25
This is very old procedure I found in past, it was faster than build-in routines, but if now Delphi can do it better the choice is simple, thanks buddies
  Mit Zitat antworten Zitat
Fritzew

Registriert seit: 18. Nov 2015
Ort: Kehl
678 Beiträge
 
Delphi 11 Alexandria
 
#5

AW: Simple asm from x86 to x64

  Alt 11. Apr 2017, 19:28
Du weist aber das du in einem deutschen Forum bist, oder?
Fritz Westermann
  Mit Zitat antworten Zitat
Benutzerbild von sh17
sh17

Registriert seit: 26. Okt 2005
Ort: Radebeul
1.597 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: Simple asm from x86 to x64

  Alt 11. Apr 2017, 20:33
Du weist aber das du in einem deutschen Forum bist, oder?
In einem der besten Delphi-Foren überhaupt, denke ich. Da darf auch mal englisch geschrieben werden.
Sven Harazim
--
  Mit Zitat antworten Zitat
Antwort Antwort


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 20: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