An die ASM Pro's

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von razor90, 9. Februar 2007 .

  1. 9. Februar 2007
    Hallo,
    hab grade ein kleines Problem mit ASM. Ich möchte eine Rechnung von VB in ASM umsetzen.

    Code:
    ret = ((r1 * (m - X) \ m) + (r2 * X \ m)) * (m - Y) \ m + ((r3 * (m - X) \ m) + (r4 * X \ m)) * Y \ m
    m = 255
    r1,r2,r3,r4,X,Y = eine 1Byte große Zahl von 0-255

    Das Ergebnis is wieder ne Zahl von 0-255, also nen Byte groß.

    Ich Benutze MASM und die Variablen r1,r2,r3,r4 und m sind per LOCAL Macro als BYTE auf dem Stack (also einfach z.b. per "mov r1, 3" ansprechbar).
    X und Y wird jeweils per Schleife von 0 bis 255 durchgelaufen und deren aktuelle wert befindet sich in CH bzw CL.
    Es können alle Register bis auf ECX und EDI benutzt werden. Wenn nötig kann man ja auch noch paar Variablen per LOCAL aufm Stack anlegen.

    Ich hoffe das mir einer helfen kann^^

    mfg r90
     
  2. 9. Februar 2007
    AW: An die ASM Pro's

    Hi hab mal den Code umgesetzt ich hoffe der funtzt hab aber keine möglichkeiten
    gehabt den zu überprüfen:

    Code:
     LOCAL r1: BYTE [COLOR="Green"];Variablen[/COLOR]
     LOCAL r2: BYTE 
     LOCAL r3: BYTE 
     LOCAL r4: BYTE 
     LOCAL M : BYTE 
     LOCAL RE: BYTE [COLOR="Green"];Variable für den Rückgabewert[/COLOR]
    
     LOCAL A: [B]BYTE [/B][COLOR="Green"];Hilfsvariablen[/COLOR]
     LOCAL B: [B]BYTE[/B]
    
     mov M, 255 
     mov CH, 0 [COLOR="Green"];X Variable[/COLOR]
     mov CL, 0 [COLOR="Green"];Y Variable[/COLOR]
    
     .while CH < 255
     
     .while CL < 255
    
     [COLOR="Green"];Hier der Code für[/COLOR]
     [COLOR="Green"];ret = ((r1 * (m - X) \ m) + (r2 * X \ m)) * (m - Y) \ m + ((r3 * (m - X) \ m) + (r4 * X \ m)) * Y \ m[/COLOR]
    
     mov al, M
     sub al, CH
     mul r1
     div M
     mov A, al
     mov al, r2
     mul CH
     div M
     add A, al
     mov al, M
     sub al, CL
     mul A
     div M
     mov A, al
     mov al, M
     sub al, CH
     mul r3
     div M
     mov B,al
     mov al,r4
     mul CH
     div M
     add al, B
     mul CL
     div M
     mov RE, al
    
     [COLOR="Green"];Bis hierhin[/COLOR]
    
    
     add CL, 1
     .endw
    
    
     add CH, 1
     .endw
    
    
    Mfg

    Rushh0ur
     
  3. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.