Hallo, bin gerade mal wieder am Spielen. Ich habe da ein Purebasic-Listing mit Inline-ASM und möchte das nun auch für den Inline-ASM in XProfan umsetzen. Leider gelingt mir das wegen meinen geringen Kenntnissen in ASM nicht so richtig. Es handlet sich um eine einfache XOR-Verschlüsselung mit Passwort.
Hier mal das Original :
Code
EnableASM
Procedure XorWithKey (sText.l, LenText.l, sKey.l, LenKey.l)
XOR ecx, ecx
MOV esi, sText
MOV edi, sKey
MOV edx, LenText
MOV ebp, LenKey
ADD ebp, esi
xornextbyte:
MOV al, [esi]
MOV bl, [edi]
XOR al, bl
MOV [esi], al
INC ecx
INC esi
INC edi
CMP esi, ebp
JGE l_xorcomplete
CMP ecx, edx
JGE l_xornextround
JMP l_xornextbyte
xornextround:
XOR ecx, ecx
SUB edi, edx
JMP l_xornextbyte
xorcomplete:
EndProcedure
sText.s = "Text to encrypt"
sKey.s = "Wayne Diamond"
;// Encrypt
XorWithKey(@sText, Len(sText), @sKey, Len(sKey))
Debug sText
;// And again, which decrypts it
XorWithKey(@sText, Len(sText), @sKey, Len(sKey))
Debug sText
Alles anzeigen
Und jetzt das, was ich mit XProfan umgesetzt habe :
Code
Declare String sText, sKey
CLS
Set("AsmMode", 0)
ASM "XorWithKey", 4 ' (sText.l, LenText.l, sKey.l, LenKey.l)
XOR ecx, ecx
MOV esi, par1
MOV edi, par3
MOV edx, par2
MOV ebp, par4
ADD ebp, esi
xornextbyte:
MOV al, [esi]
MOV bl, [edi]
XOR al, bl
MOV [esi], al
INC ecx
INC esi
INC edi
CMP esi, ebp
JGE xorcomplete
CMP ecx, edx
JGE xornextround
JMP xornextbyte
xornextround:
XOR ecx, ecx
SUB edi, edx
JMP xornextbyte
xorcomplete:
EndAsm
sText = "Text to encrypt"
sKey = "Wayne Diamond"
' Encrypt
XorWithKey(sText, Len(sText), sKey, Len(sKey))
Print sText
' And again, which decrypts it
XorWithKey(sText, Len(sText), sKey, Len(sKey))
Print sText
WaitKey
Alles anzeigen
Das Programm bleibt hängen und sonst tut sich nichts.
Evtl. kann mir ja einer der Profis, wie z.b. Volkmar, weiterhelfen.