Sign in to follow this  
Followers 0
EcKo

write asm in a script

13 posts in this topic

hello,

is there a way to write asm directly in a script?

so that i can just write something like this

mov  edi, edi
      push ebp
      mov  ebp, esp

thank you in advance

Share this post


Link to post
Share on other sites



http://www.autoitscript.com/forum/index.php?showtopic=111613

This topic shows you how to use assembly inside a script. Good luck :(

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

The script would save the string to a file, then use Run() or ShellExecute() to pass that file into your assembler with appropriate command line switches.

If you mean "Will AutoIt interpret ASM?" then the answer is NO.

:(

Edit: JRowe had a better answer, but it's still passing the ASM to an external assembler.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

The script would save the string to a file, then use Run() or ShellExecute() to pass that file into your assembler with appropriate command line switches.

If you mean "Will AutoIt interpret ASM?" then the answer is NO.

:(

Edit: JRowe had a better answer, but it's still passing the ASM to an external assembler.

There is no difference between interpreting "ASM" and using DllCall() function as far as AutoIt's interpretation is concerned.

If AutoIt is interpreting (pseudo-like code) DllCall("Beep") then AutoIt is interpreting "ASM" too.

Assembler assembles, nothging more. You don't need it strictly speaking if you are capable of assembling the code your self.

edit: But I see what you mean (and what I missed) after rereading your post.

Yashied's reply is shit from more than one perspective.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This is AutoIt for you!? No, I do not have claims against the author, just an example. It's difficult and not clear for most people on this forum, AutoIt dedicated. Then the questions begin: Ah, it does not work, Oh, it stuck...

AsmReset($AsmObj)

    ;hier gehts los^^
    AsmAdd($AsmObj, "   push ebp                ");Basepointer Register sichern, not really needed, there is no registerpressure^^

    AsmAdd($AsmObj, "   finit                   ");copro init
    AsmAdd($AsmObj, "   mov  ebp,dword[ESP+08]  ");lade den Inhalt der 2-Byte-Adresse an der position des 1. Elementes der asmstack-struct ins register EBP (pointer auf die struct)
                                                ;EBP ist nun ganz normal zu verwenden und zeigt auf die ьbergebenen Parameter
    AsmAdd($AsmObj, "   fld qword[EBP+10]       ");lade die 4 bytes(qword) an der Position Structanfang+10h Bytes in den Coprozessor-Stack  st(0)=stepx
    ;Damit man nachvollziehen kann, wie die Berechnung vor sich geht, zeige ich immer den aktuellen Copro-Stack
    ;st(0)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP+18]       ");st(0)=stepy
    ;st(0)   =stepy
    ;st(1)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP]          ");st(0)=startx=x0 x-position
    ;st(0)   =x0
    ;st(1)   =stepy
    ;st(2)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP+08]       ");st(0)=starty y0
    ;st(0)   =y0
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx
    AsmAdd($AsmObj, "   fld st(1)               ");st(0)=x
    ;st(0)   =x
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fld st(1)               ");st(0)=y
    ;st(0)   =y
    ;st(1)   =x
    ;st(2)   =y0
    ;st(3)   =x0
    ;st(4)   =stepy
    ;st(5)   =stepx

    ;alle fьr die Berechnung notwendigen Parameter in die Prozessor-Register eintragen

    AsmAdd($AsmObj, "   mov edi,dword[EBP+28]   ");startadresse bitmapdaten
    AsmAdd($AsmObj, "   mov eax,dword[EBP+2c]   ");eax=winwidth
    AsmAdd($AsmObj, "   mov ebx,dword[EBP+30]   ");ebx=winheight
    AsmAdd($AsmObj, "   mul ebx                 ");eax = winheight*winwidth
    AsmAdd($AsmObj, "   shl eax,2               ");eax = winheight*winwidth*4 jedes pixel besteht aus 4 Byte
    AsmAdd($AsmObj, "   add eax,edi             ");eax = Adresse letztes pixel der Bitmap
    AsmAdd($AsmObj, "   mov ebx,eax             ");EBX = Adresse letztes pixel der Bitmap
    AsmAdd($AsmObj, "   mov eax,0               ");EAX = wird die Anzahl der berechneten Iterationen
    AsmAdd($AsmObj, "   mov ecx,0               ");ECX = counter fьr Pixelposition in einer Zeile, wenn >width, dann wieder 0
    AsmAdd($AsmObj, "   mov edx,dword[EBP+20]   ");EDX = tiefe
    AsmAdd($AsmObj, "   mov esi,dword[EBP+38]   ");Pointer auf die 2. Bitmap, diese enthдlt die durch die Palette umgewandelten Farbpixel
;~  AsmAdd($AsmObj, "   mov eax,esi ")
;~  AsmAdd($AsmObj, "   pop ebp                 ");register wiederherstellen
;~  AsmAdd($AsmObj, "   ret                     ");Rьcksprung nach AutoIt

    AsmAdd($AsmObj, "   loop:                   ");Einsprungpunkt fьr die schleife
    AsmAdd($AsmObj, "   jmp $+3d                ");springe in die Berechnung der Iteration nach @berechnung
    AsmAdd($AsmObj, "   limit:                  ");Rьcksprungpunkt aus der Berechnung der MAXIteration = EAX, limit erreicht
    AsmAdd($AsmObj, "   mov eax,0               ");Rьcksprungpunkt aus der Berechnung der Iteration = EAX , gewissermassen die "Farbe"
    AsmAdd($AsmObj, "   ergebnis:               ");Rьcksprungpunkt aus der Berechnung der Iteration = EAX , gewissermassen die "Farbe"

;Hier ist der Rьcksprungpunkt der Berechnungsroutine, in EAX steht die Anzahl der Iterationen also gewissermassen die "Farbe"
;EAX (4 Byte)) wird als "Farbe (AABBGGRR auch 4 Byte)" direkt an die Speicherstelle des Pixels geschrieben
;hier kцnnte man auch direkt auf eine Farbpalette zugreifen oder den EAX-Wert durch Berechnungen anpassen
;allerdings mьssen die Adressen der absoluten Vorwдrtssprьnge (der jmp nach loop: und vor ergebnis:) von Hand angepasst werden => Debugger hilft
    AsmAdd($AsmObj, "   push edx                ");EDX sichern auf den Stack   ACHTUNG! Ergebnis von mul ist EDX:EAX!!!! EDX wird verдndert !
    AsmAdd($AsmObj, "   push ebx                ");uuuuhhhh, registerpressure^^
    AsmAdd($AsmObj, "   mov dword[EDI],eax      ");stosd  ^^, speichere EAX an adresse ES:EDI (EDI+4) position des pixels in der bitmap
    ;nun in der zweiten Bitmap die Pixelfarbe aus der Palette holen
    AsmAdd($AsmObj, "   xor edx,edx             ");EDX=0
    AsmAdd($AsmObj, "   mov ebx,0FFh            ");EBX=255
    AsmAdd($AsmObj, "   div ebx                 ");in EAX steht nun die integerdivision, in EDX steht der Rest! =>edx=modulo(eax,ebx)

    AsmAdd($AsmObj, "   mov eax,dword[EBP+3C]   ");anfang der palette
    AsmAdd($AsmObj, "   shl edx,2               ");edx=edx*4  4 Byte pro Farbe in der palette
    AsmAdd($AsmObj, "   add edx,eax             ");Adresse der Farbe in der palette
    AsmAdd($AsmObj, "   mov eax,dword[edx+01]   ");Farbe in der palette
    AsmAdd($AsmObj, "   mov dword[ESI],eax      ");Farbe aus der palette in die 2. Bitmap schreiben

    AsmAdd($AsmObj, "   pop ebx                 ")
    AsmAdd($AsmObj, "   pop edx                 ");EDX vom Stack

    AsmAdd($AsmObj, "   add EDI,4               ");4 Byte dahinter ist die nдchste Pixeladresse(Orginaldaten)
    AsmAdd($AsmObj, "   add ESI,4               ");4 Byte dahinter ist die nдchste Pixeladresse(2.Bitmap)
    AsmAdd($AsmObj, "   cmp edi,ebx             ");Vergleich aktuelle Pixeladresse mit der letzten Pixeladresse der Bitmap
    AsmAdd($AsmObj, "   jne @LOOP               ");springe, wenn nicht gleich (Jump if Not Equal) nach loop: , wenn gleich dann sind alle Pixel berechnet

;   AsmAdd($AsmObj, "   finit                   ");copro init
    AsmAdd($AsmObj, "   pop ebp                 ");register wiederherstellen
    AsmAdd($AsmObj, "   ret                     ");Rьcksprung nach AutoIt


    AsmAdd($AsmObj, "   berechnung:             ")
    ;stack bereinigen, aktuellex x und y auf den stack
    AsmAdd($AsmObj, "   fstp st(0)              ");POP stack
    ;st(0)   =x
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fstp st(0)              ");POP stack
    ;st(0)   =y0
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx
    ;******************x0=x0+stepx
    AsmAdd($AsmObj, "   fld ST(3)               ");st(0)=stepx
    ;st(0)   =stepx
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   faddp ST(2),ST(0)       ");st(2)=x0+stepx  POP
    ;st(0)   =y0
    ;st(1)   =x0+stepx
    ;st(2)   =stepy
    ;st(3)   =stepx

    AsmAdd($AsmObj, "   mov eax,0               ");ax = 0

    AsmAdd($AsmObj, "   cmp ecx,dword[EBP+2C]   ");vgl ecx mit fensterbreite
    AsmAdd($AsmObj, "   jl $+2c                 ");wenn micht grцЯer, dann springe zum start1   +2c    16 ohne callback
    AsmAdd($AsmObj, "   mov ecx,0               ");zдhler an den Zeilenanfang der Bitmap
    AsmAdd($AsmObj, "   fsave [ebp+40]          ");alle Coprozessorregister und den Copro-stack sichern
    AsmAdd($AsmObj, "   pushad                  ");alle Prozessorregister sichern
    AsmAdd($AsmObj, "   mov eax,dword[EBP+34]   ");Adresse der AutoItfunktion in eax laden, evtl Parameter vorher auf den stack pushen
    AsmAdd($AsmOBj, "   call eax                ");AutoIt-Funktion aufrufen, erlaubt einen Interrupt, ansonsten wдre das Fenster wдhrend der gesamten Berechnung blockiert
    AsmAdd($AsmObj, "   popad                   ");Prozessorregister alle wiederherstellen
    AsmAdd($AsmObj, "   frstor [ebp+40]         ");coproregister und coprostack wiederherstellen
    AsmAdd($AsmObj, "   fld ST(2)               ");y0=y0+stepy
    ;st(0)   =stepy
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   faddp ST(1),ST(0)       ");y0=y0+stepy und POP
    ;st(0)   =y0+stepy
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP]          ");ST(0)= startx, die spaltenziffern bleiben immer gleich
    ;st(0)   =startx=neues x0
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fxch ST(2)              ");tausche st(2) mit st(0)
    ;st(0)   =x0
    ;st(1)   =y0
    ;st(2)   =startx=neues x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fstp st(0)               ");POP
    ;st(0)   =y0
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx

    AsmAdd($AsmObj, "   start1:                 ");Stack wieder aufbauen fьr die Berechnung

    AsmAdd($AsmObj, "   inc ecx                 ");ecx=ecx+1 = ein pixel weiter
    AsmAdd($AsmObj, "   fld ST(1)               ");x => st(0)
    ;st(0)   =x
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fld ST(1)               ");y => st(0)
    ;st(0)   =y
    ;st(1)   =x
    ;st(2)   =y0
    ;st(3)   =x0
    ;st(4)   =stepy
    ;st(5)   =stepx

    AsmAdd($AsmObj, "   start:                  ");die "innere schleife" , Berechnung von x^2-y^2+x0 und 2*x*y+y0 und vergleich
    AsmAdd($AsmObj, "   fld ST(1)               ");x => st(0)
    ;st(0)   =x
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = x^2
    ;st(0)   =x^2
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fld ST(1)               "); y=> st(0)
    ;st(0)   =y
    ;st(1)   =x^2
    ;st(2)   =y
    ;st(3)   =x
    ;st(4)   =y0
    ;st(5)   =x0
    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = y^2
    ;st(0)   =y^2
    ;st(1)   =x^2
    ;st(2)   =y
    ;st(3)   =x
    ;st(4)   =y0
    ;st(5)   =x0

    AsmAdd($AsmObj, "   fsubp ST(1),ST(0)       ");st(0) = x^2-y^2
    ;st(0)   =x^2-y^2
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fadd ST(0),ST(4)        ");st(0) = x^2-y^2+x0

    ;st(0)   =x^2-y^2+x0
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fxch ST(2)              ");st(0) = x

    ;st(0)   =x
    ;st(1)   =y
    ;st(2)   =x^2-y^2+x0
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fmulp ST(1),ST(0)       ");st(0) = x*y
    ;st(0)   =y*x
    ;st(1)   =x^2-y^2+x0
    ;st(2)   =y0
    ;st(3)   =x0

    AsmAdd($AsmObj, "   fadd ST(0),ST(0)        ");st(0) = x*y+x*y = 2*x*y
    ;st(0)   =2*y*x
    ;st(1)   =x^2-y^2+x0
    ;st(2)   =y0
    ;st(3)   =x0

    AsmAdd($AsmObj, "   fadd ST(0),ST(2)        ");st(0) = x*y+x*y+y = 2*x*y+y0
    ;   AsmAdd($AsmObj, "   jmp  @exit           ");ansonsten wieder zum :start
    ;st(0)   =2*y*x+y0      neues y
    ;st(1)   =x^2-y^2+x0    neues x
    ;st(2)   =y0
    ;st(§)   =x0

    AsmAdd($AsmObj, "   fld ST(0)               ");st(0) = y
    ;st(0)   =y
    ;st(1)   =2*y*x+y0     neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = y^2
    ;st(0)   =y^2
    ;st(1)   =2*y*x+y0     neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fld ST(2)               ");st(0) = x
    ;st(0)   =x
    ;st(1)   =y^2
    ;st(2)   =2*y*x+y0     neues y
    ;st(3)   =x^2-y^2+x0    neues x
    ;st(4)   =y0
    ;st(5)   =x0
    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = x^2
    ;st(0)   =x^2
    ;st(1)   =y^2
    ;st(2)   =2*y*x+y0     neues y
    ;st(3)   =x^2-y^2+x0    neues x
    ;st(4)   =y0
    ;st(5)   =x0
    AsmAdd($AsmObj, "   faddp ST(1),ST(0)       ");st(0) = y^2+x^2
    ;AsmAdd($AsmObj, "      jmp  @exit           ");ansonsten wieder zum :start
    ;st(0)   =y^2+x^2
    ;st(1)   =2*y*x+y0     neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fistp dword [EBP+20]    ");aktuellen wert speichern
    ;st(1)   =2*y*x+y0      neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   cmp dword[EBP+20],edx   ");ist y^2+x^2>tiefe vergleich
    AsmAdd($AsmObj, "   ja  @ergebnis           ");wenn y^2+x^2 > tiefe  dann farbe=eax ausgeben
    AsmAdd($AsmObj, "   cmp eax,dword[EBP+24]   ");vgl maxiter mit aktueller iteration
    AsmAdd($AsmObj, "   ja  @limit              ");wenn grцЯer, dann farbe=0 ausgeben
    AsmAdd($AsmObj, "   inc eax                 ");ax = ax + 1
    AsmAdd($AsmObj, "   jmp  @start             ");ansonsten wieder zum :start

Edited by Yashied

Share this post


Link to post
Share on other sites

This is AutoIt for you!? No, I do not have claims against the author, just an example. It's difficult and not clear for most people on this forum, AutoIt dedicated. Then the questions begin: Ah, it does not work, Oh, it stuck...

AsmReset($AsmObj)

    ;hier gehts los^^
    AsmAdd($AsmObj, "   push ebp                ");Basepointer Register sichern, not really needed, there is no registerpressure^^

    AsmAdd($AsmObj, "   finit                   ");copro init
    AsmAdd($AsmObj, "   mov  ebp,dword[ESP+08]  ");lade den Inhalt der 2-Byte-Adresse an der position des 1. Elementes der asmstack-struct ins register EBP (pointer auf die struct)
                                                ;EBP ist nun ganz normal zu verwenden und zeigt auf die ьbergebenen Parameter
    AsmAdd($AsmObj, "   fld qword[EBP+10]       ");lade die 4 bytes(qword) an der Position Structanfang+10h Bytes in den Coprozessor-Stack  st(0)=stepx
    ;Damit man nachvollziehen kann, wie die Berechnung vor sich geht, zeige ich immer den aktuellen Copro-Stack
    ;st(0)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP+18]       ");st(0)=stepy
    ;st(0)   =stepy
    ;st(1)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP]          ");st(0)=startx=x0 x-position
    ;st(0)   =x0
    ;st(1)   =stepy
    ;st(2)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP+08]       ");st(0)=starty y0
    ;st(0)   =y0
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx
    AsmAdd($AsmObj, "   fld st(1)               ");st(0)=x
    ;st(0)   =x
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fld st(1)               ");st(0)=y
    ;st(0)   =y
    ;st(1)   =x
    ;st(2)   =y0
    ;st(3)   =x0
    ;st(4)   =stepy
    ;st(5)   =stepx

    ;alle fьr die Berechnung notwendigen Parameter in die Prozessor-Register eintragen

    AsmAdd($AsmObj, "   mov edi,dword[EBP+28]   ");startadresse bitmapdaten
    AsmAdd($AsmObj, "   mov eax,dword[EBP+2c]   ");eax=winwidth
    AsmAdd($AsmObj, "   mov ebx,dword[EBP+30]   ");ebx=winheight
    AsmAdd($AsmObj, "   mul ebx                 ");eax = winheight*winwidth
    AsmAdd($AsmObj, "   shl eax,2               ");eax = winheight*winwidth*4 jedes pixel besteht aus 4 Byte
    AsmAdd($AsmObj, "   add eax,edi             ");eax = Adresse letztes pixel der Bitmap
    AsmAdd($AsmObj, "   mov ebx,eax             ");EBX = Adresse letztes pixel der Bitmap
    AsmAdd($AsmObj, "   mov eax,0               ");EAX = wird die Anzahl der berechneten Iterationen
    AsmAdd($AsmObj, "   mov ecx,0               ");ECX = counter fьr Pixelposition in einer Zeile, wenn >width, dann wieder 0
    AsmAdd($AsmObj, "   mov edx,dword[EBP+20]   ");EDX = tiefe
    AsmAdd($AsmObj, "   mov esi,dword[EBP+38]   ");Pointer auf die 2. Bitmap, diese enthдlt die durch die Palette umgewandelten Farbpixel
;~  AsmAdd($AsmObj, "   mov eax,esi ")
;~  AsmAdd($AsmObj, "   pop ebp                 ");register wiederherstellen
;~  AsmAdd($AsmObj, "   ret                     ");Rьcksprung nach AutoIt

    AsmAdd($AsmObj, "   loop:                   ");Einsprungpunkt fьr die schleife
    AsmAdd($AsmObj, "   jmp $+3d                ");springe in die Berechnung der Iteration nach @berechnung
    AsmAdd($AsmObj, "   limit:                  ");Rьcksprungpunkt aus der Berechnung der MAXIteration = EAX, limit erreicht
    AsmAdd($AsmObj, "   mov eax,0               ");Rьcksprungpunkt aus der Berechnung der Iteration = EAX , gewissermassen die "Farbe"
    AsmAdd($AsmObj, "   ergebnis:               ");Rьcksprungpunkt aus der Berechnung der Iteration = EAX , gewissermassen die "Farbe"

;Hier ist der Rьcksprungpunkt der Berechnungsroutine, in EAX steht die Anzahl der Iterationen also gewissermassen die "Farbe"
;EAX (4 Byte)) wird als "Farbe (AABBGGRR auch 4 Byte)" direkt an die Speicherstelle des Pixels geschrieben
;hier kцnnte man auch direkt auf eine Farbpalette zugreifen oder den EAX-Wert durch Berechnungen anpassen
;allerdings mьssen die Adressen der absoluten Vorwдrtssprьnge (der jmp nach loop: und vor ergebnis:) von Hand angepasst werden => Debugger hilft
    AsmAdd($AsmObj, "   push edx                ");EDX sichern auf den Stack   ACHTUNG! Ergebnis von mul ist EDX:EAX!!!! EDX wird verдndert !
    AsmAdd($AsmObj, "   push ebx                ");uuuuhhhh, registerpressure^^
    AsmAdd($AsmObj, "   mov dword[EDI],eax      ");stosd  ^^, speichere EAX an adresse ES:EDI (EDI+4) position des pixels in der bitmap
    ;nun in der zweiten Bitmap die Pixelfarbe aus der Palette holen
    AsmAdd($AsmObj, "   xor edx,edx             ");EDX=0
    AsmAdd($AsmObj, "   mov ebx,0FFh            ");EBX=255
    AsmAdd($AsmObj, "   div ebx                 ");in EAX steht nun die integerdivision, in EDX steht der Rest! =>edx=modulo(eax,ebx)

    AsmAdd($AsmObj, "   mov eax,dword[EBP+3C]   ");anfang der palette
    AsmAdd($AsmObj, "   shl edx,2               ");edx=edx*4  4 Byte pro Farbe in der palette
    AsmAdd($AsmObj, "   add edx,eax             ");Adresse der Farbe in der palette
    AsmAdd($AsmObj, "   mov eax,dword[edx+01]   ");Farbe in der palette
    AsmAdd($AsmObj, "   mov dword[ESI],eax      ");Farbe aus der palette in die 2. Bitmap schreiben

    AsmAdd($AsmObj, "   pop ebx                 ")
    AsmAdd($AsmObj, "   pop edx                 ");EDX vom Stack

    AsmAdd($AsmObj, "   add EDI,4               ");4 Byte dahinter ist die nдchste Pixeladresse(Orginaldaten)
    AsmAdd($AsmObj, "   add ESI,4               ");4 Byte dahinter ist die nдchste Pixeladresse(2.Bitmap)
    AsmAdd($AsmObj, "   cmp edi,ebx             ");Vergleich aktuelle Pixeladresse mit der letzten Pixeladresse der Bitmap
    AsmAdd($AsmObj, "   jne @LOOP               ");springe, wenn nicht gleich (Jump if Not Equal) nach loop: , wenn gleich dann sind alle Pixel berechnet

;   AsmAdd($AsmObj, "   finit                   ");copro init
    AsmAdd($AsmObj, "   pop ebp                 ");register wiederherstellen
    AsmAdd($AsmObj, "   ret                     ");Rьcksprung nach AutoIt


    AsmAdd($AsmObj, "   berechnung:             ")
    ;stack bereinigen, aktuellex x und y auf den stack
    AsmAdd($AsmObj, "   fstp st(0)              ");POP stack
    ;st(0)   =x
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fstp st(0)              ");POP stack
    ;st(0)   =y0
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx
    ;******************x0=x0+stepx
    AsmAdd($AsmObj, "   fld ST(3)               ");st(0)=stepx
    ;st(0)   =stepx
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   faddp ST(2),ST(0)       ");st(2)=x0+stepx  POP
    ;st(0)   =y0
    ;st(1)   =x0+stepx
    ;st(2)   =stepy
    ;st(3)   =stepx

    AsmAdd($AsmObj, "   mov eax,0               ");ax = 0

    AsmAdd($AsmObj, "   cmp ecx,dword[EBP+2C]   ");vgl ecx mit fensterbreite
    AsmAdd($AsmObj, "   jl $+2c                 ");wenn micht grцЯer, dann springe zum start1   +2c    16 ohne callback
    AsmAdd($AsmObj, "   mov ecx,0               ");zдhler an den Zeilenanfang der Bitmap
    AsmAdd($AsmObj, "   fsave [ebp+40]          ");alle Coprozessorregister und den Copro-stack sichern
    AsmAdd($AsmObj, "   pushad                  ");alle Prozessorregister sichern
    AsmAdd($AsmObj, "   mov eax,dword[EBP+34]   ");Adresse der AutoItfunktion in eax laden, evtl Parameter vorher auf den stack pushen
    AsmAdd($AsmOBj, "   call eax                ");AutoIt-Funktion aufrufen, erlaubt einen Interrupt, ansonsten wдre das Fenster wдhrend der gesamten Berechnung blockiert
    AsmAdd($AsmObj, "   popad                   ");Prozessorregister alle wiederherstellen
    AsmAdd($AsmObj, "   frstor [ebp+40]         ");coproregister und coprostack wiederherstellen
    AsmAdd($AsmObj, "   fld ST(2)               ");y0=y0+stepy
    ;st(0)   =stepy
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   faddp ST(1),ST(0)       ");y0=y0+stepy und POP
    ;st(0)   =y0+stepy
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx
    AsmAdd($AsmObj, "   fld qword[EBP]          ");ST(0)= startx, die spaltenziffern bleiben immer gleich
    ;st(0)   =startx=neues x0
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fxch ST(2)              ");tausche st(2) mit st(0)
    ;st(0)   =x0
    ;st(1)   =y0
    ;st(2)   =startx=neues x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fstp st(0)               ");POP
    ;st(0)   =y0
    ;st(1)   =x0
    ;st(2)   =stepy
    ;st(3)   =stepx

    AsmAdd($AsmObj, "   start1:                 ");Stack wieder aufbauen fьr die Berechnung

    AsmAdd($AsmObj, "   inc ecx                 ");ecx=ecx+1 = ein pixel weiter
    AsmAdd($AsmObj, "   fld ST(1)               ");x => st(0)
    ;st(0)   =x
    ;st(1)   =y0
    ;st(2)   =x0
    ;st(3)   =stepy
    ;st(4)   =stepx
    AsmAdd($AsmObj, "   fld ST(1)               ");y => st(0)
    ;st(0)   =y
    ;st(1)   =x
    ;st(2)   =y0
    ;st(3)   =x0
    ;st(4)   =stepy
    ;st(5)   =stepx

    AsmAdd($AsmObj, "   start:                  ");die "innere schleife" , Berechnung von x^2-y^2+x0 und 2*x*y+y0 und vergleich
    AsmAdd($AsmObj, "   fld ST(1)               ");x => st(0)
    ;st(0)   =x
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = x^2
    ;st(0)   =x^2
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fld ST(1)               "); y=> st(0)
    ;st(0)   =y
    ;st(1)   =x^2
    ;st(2)   =y
    ;st(3)   =x
    ;st(4)   =y0
    ;st(5)   =x0
    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = y^2
    ;st(0)   =y^2
    ;st(1)   =x^2
    ;st(2)   =y
    ;st(3)   =x
    ;st(4)   =y0
    ;st(5)   =x0

    AsmAdd($AsmObj, "   fsubp ST(1),ST(0)       ");st(0) = x^2-y^2
    ;st(0)   =x^2-y^2
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fadd ST(0),ST(4)        ");st(0) = x^2-y^2+x0

    ;st(0)   =x^2-y^2+x0
    ;st(1)   =y
    ;st(2)   =x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fxch ST(2)              ");st(0) = x

    ;st(0)   =x
    ;st(1)   =y
    ;st(2)   =x^2-y^2+x0
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fmulp ST(1),ST(0)       ");st(0) = x*y
    ;st(0)   =y*x
    ;st(1)   =x^2-y^2+x0
    ;st(2)   =y0
    ;st(3)   =x0

    AsmAdd($AsmObj, "   fadd ST(0),ST(0)        ");st(0) = x*y+x*y = 2*x*y
    ;st(0)   =2*y*x
    ;st(1)   =x^2-y^2+x0
    ;st(2)   =y0
    ;st(3)   =x0

    AsmAdd($AsmObj, "   fadd ST(0),ST(2)        ");st(0) = x*y+x*y+y = 2*x*y+y0
    ;   AsmAdd($AsmObj, "   jmp  @exit           ");ansonsten wieder zum :start
    ;st(0)   =2*y*x+y0      neues y
    ;st(1)   =x^2-y^2+x0    neues x
    ;st(2)   =y0
    ;st(§)   =x0

    AsmAdd($AsmObj, "   fld ST(0)               ");st(0) = y
    ;st(0)   =y
    ;st(1)   =2*y*x+y0     neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = y^2
    ;st(0)   =y^2
    ;st(1)   =2*y*x+y0     neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   fld ST(2)               ");st(0) = x
    ;st(0)   =x
    ;st(1)   =y^2
    ;st(2)   =2*y*x+y0     neues y
    ;st(3)   =x^2-y^2+x0    neues x
    ;st(4)   =y0
    ;st(5)   =x0
    AsmAdd($AsmObj, "   fmul ST(0),ST(0)        ");st(0) = x^2
    ;st(0)   =x^2
    ;st(1)   =y^2
    ;st(2)   =2*y*x+y0     neues y
    ;st(3)   =x^2-y^2+x0    neues x
    ;st(4)   =y0
    ;st(5)   =x0
    AsmAdd($AsmObj, "   faddp ST(1),ST(0)       ");st(0) = y^2+x^2
    ;AsmAdd($AsmObj, "      jmp  @exit           ");ansonsten wieder zum :start
    ;st(0)   =y^2+x^2
    ;st(1)   =2*y*x+y0     neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0

    AsmAdd($AsmObj, "   fistp dword [EBP+20]    ");aktuellen wert speichern
    ;st(1)   =2*y*x+y0      neues y
    ;st(2)   =x^2-y^2+x0    neues x
    ;st(3)   =y0
    ;st(4)   =x0
    AsmAdd($AsmObj, "   cmp dword[EBP+20],edx   ");ist y^2+x^2>tiefe vergleich
    AsmAdd($AsmObj, "   ja  @ergebnis           ");wenn y^2+x^2 > tiefe  dann farbe=eax ausgeben
    AsmAdd($AsmObj, "   cmp eax,dword[EBP+24]   ");vgl maxiter mit aktueller iteration
    AsmAdd($AsmObj, "   ja  @limit              ");wenn grцЯer, dann farbe=0 ausgeben
    AsmAdd($AsmObj, "   inc eax                 ");ax = ax + 1
    AsmAdd($AsmObj, "   jmp  @start             ");ansonsten wieder zum :start

I really don't know what to say.

What you wrote is so unbelievably dumb.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

hmm...ok, so in this case a better alternative would be to make it just load a dll with the asm in it?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

No. There is no "better" or "worse" in this case. If you're comfortable putting programs together with FASM, you can use that inside AutoIt, or you can write dlls and export functions using assembly, then use DllCall() on the exported functions. There are multiple routes to take. The one you pick depends on what you want to do.

You can abstract things to the extreme, even, by creating a function in c that calls code written in assembly that's called by a plugin function. Or you can embed directly inside a script. It's up to you how messy you want things to get, especially since there are simple ways of manipulating raw assembly now.

trancexx has created multiple examples of using assembly directly inside a script, without a nice UDF encapsulating conveniences like the FASM udf. Check out the examples forum to see advanced embedded assembly in some of trancexx's scripts.

In my opinion, Ward's inline assembly UDF would be the quickest route to allow you to experiment with assembly. Your original question is best answered by using that functionality.

Edited by JRowe

Share this post


Link to post
Share on other sites

Honestly, if you know Assembly you shouldn't be coding in Autoit.

Apples and moon rocks.

Object Oriented AutoIt is due to people doing things they "shouldn't" have been doing, according to you.

Here's a hint, and I don't meant this to be mean or snide or anything: Should and shouldn't don't ever come into it. AutoIt is not constrained by the uses you envisage for it.

It's a very capable language that can be used for anything that the mainstream languages like Python and Java can be used for. Are you going to get comparable performance? Probably not. Then again, you can optimize from the inside... using embedded assembly, plugins, and dlls.

It's a matter of passion and desire. If you're passionate about something or desire to do it enough, then go for it. Arbitrary "shoulds" and "shouldnts" are meaningless in that context.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Honestly, if you know Assembly you shouldn't be coding in Autoit :)

well, i know assembly yes, but writing a whole program in assembly is tedious and i dont have the patience for it

so i let some high level language do most of the job for me, and something i specifically want to be done ill do it myself :(

now i got another question (i think i should've asked this one before the first one)

its generally not related to autoit, but might aswell ask here.

is it possible to write an api in a dll and make a program use this dll instead of e.g. user32.dll

for example:

write a function similar (or exactly the same) as GetCursorPos in user32.dll and make the program use this instead of user32.dll?

edit: thnx for the replies so far :)

Edited by EcKo

Share this post


Link to post
Share on other sites

Apples and moon rocks.

Object Oriented AutoIt is due to people doing things they "shouldn't" have been doing, according to you.

Here's a hint, and I don't meant this to be mean or snide or anything: Should and shouldn't don't ever come into it. AutoIt is not constrained by the uses you envisage for it.

It's a very capable language that can be used for anything that the mainstream languages like Python and Java can be used for. Are you going to get comparable performance? Probably not. Then again, you can optimize from the inside... using embedded assembly, plugins, and dlls.

It's a matter of passion and desire. If you're passionate about something or desire to do it enough, then go for it. Arbitrary "shoulds" and "shouldnts" are meaningless in that context.

I just expected someone who knows Assembly, they would be using a different language. Autoit is fine, no problems with it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0