Autoit3 Library – Inline Assembly (assembler gebruiken)
Met de Inline Assembly UDF voor Autoit3 kun je assembler toepassen tussen de autoit3 code. Website Voorbeeld:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
#include <ASM.au3> ; Initial an asm object Global $Asm = AsmInit() Demo1() Demo2() Demo3() Demo4() Func Demo1() ; Demo 1: Using Parameters AsmReset($Asm) AsmAdd($Asm, "push ebp") AsmAdd($Asm, "mov ebp, esp") AsmAdd($Asm, "mov eax, [ebp + 08]") AsmAdd($Asm, "add eax, [ebp + 0c]") AsmAdd($Asm, "pop ebp") AsmAdd($Asm, "retn 8") ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF) $Ret = MemoryFuncCall("int", AsmGetPtr($Asm), "int", 1, "int", 2) MsgBox(0, "Demo 1: Using Parameters", "1 + 2 = " & $Ret[0]) EndFunc Func Demo2() ; Demo 2: Read Time-Stamp Counter AsmReset($Asm) AsmAdd($Asm, "push ebp") AsmAdd($Asm, "mov ebp, esp") AsmAdd($Asm, "rdtsc") AsmAdd($Asm, "mov ecx, [ebp + 08]") AsmAdd($Asm, "mov [ecx], edx") AsmAdd($Asm, "pop ebp") AsmAdd($Asm, "retn 4") ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF) $Ret = MemoryFuncCall("uint", AsmGetPtr($Asm), "uint*", 0) MsgBox(0, "Demo 2: Read Time-Stamp Counter", "RDTSC = " & Hex($Ret[1]) & Hex($Ret[0], 8)) Return Hex($Ret[1]) & Hex($Ret[0], 8) EndFunc Func Demo3() ; Demo 3: Using Label AsmReset($Asm) AsmAdd($Asm, "mov eax, 0") AsmAdd($Asm, "mov ecx, 10") AsmAdd($Asm, "label:") AsmAdd($Asm, "inc eax") AsmAdd($Asm, "loop @label") AsmAdd($Asm, "ret") ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF) $Ret = MemoryFuncCall("int", AsmGetPtr($Asm)) MsgBox(0, "Demo 3: Using Label", "loop label for " & $Ret[0] & " times") EndFunc Func Demo4() ; Demo 4: Call AutoIt Func From Assembly $AutoItFunc = DllCallbackRegister("AutoItFunc", "int", "") AsmReset($Asm) AsmAdd($Asm, "call " & DllCallbackGetPtr($AutoItFunc)) AsmAdd($Asm, "shl eax, 1") AsmAdd($Asm, "ret") ConsoleWrite(String(AsmGetBinary($Asm)) & @CRLF) $Ret = MemoryFuncCall("int", AsmGetPtr($Asm)) MsgBox(0, "Demo 4: AutoIt Function", "BitShift return value of AutoItFunc: " & $Ret[0]) DllCallbackFree($AutoItFunc) EndFunc Func AutoItFunc() MsgBox(0, "AutoItFunc", "Called by Inline Assembly") Return 123 EndFunc ; Release the asm object AsmExit($Asm) Exit |
[#/autoit3/libraries/inline_assembly” ]