Results 1 to 4 of 4

Thread: ASM

  1. #1

    ASM

    I am trying to get an MMX routine working using ASM and dont quite know how to get the 4 words out of mm0 back into my destination bitmap...

    This is my test routine:-

    for iX := 0 to Image1.Picture.Bitmap.Height - 1 do
    begin
    pSrc := Image1.Picture.Bitmap.ScanLine[iX];
    pDest := Image2.Picture.Bitmap.ScanLine[iX];
    iY := 0;
    while iY < Image1.Picture.Bitmap.Width - 1 do
    begin
    asm
    push EAX
    push EDX
    push ECX

    mov EAX, pSrc
    mov EDX, pDest
    db $0F,$6F,$00 /// movq mm0, [EAX]
    db $0F,$FD,$02 /// paddw mm0, [EDX]
    db $0F,$7F,$01 /// movq [ECX], mm0
    {this is the point I need to get the 4 x words out of mm0 into the scanline using pDest[iY], at the moment its outputting it to ECX}

    pop ECX
    pop EDX
    pop EAX

    end;
    Inc(iY,4);
    pSrc := Pointer(Cardinal(pSrc) + 4);
    pDest := Pointer(Cardinal(pDest) + 4);
    end;
    end;


    Any ideas?

    Thanks
    http://www.c5software.co.uk (site is being developed at the moment)

  2. #2

    ASM

    Bah, just noticed a couple of problems with this code anyways... I am putting a pointer into mm0 to start with instead of 4 x words, and I am only incrementing my pointers by 4 instead of 8... Assuming 8 is correct for 4 words? The pointers are type Pointer btw.
    http://www.c5software.co.uk (site is being developed at the moment)

  3. #3

    ASM

    [pascal]
    Sorted...

    for iX := Image1.Picture.Bitmap.Height - 1 downto 0 do
    begin
    pSrc := Image1.Picture.Bitmap.ScanLine[iX];
    pDest := Image2.Picture.Bitmap.ScanLine[iX];
    iY := Image1.Picture.Bitmap.Width - 5;
    while iY > 0 do
    begin

    IMASK64 := $F7DEF7DEF7DEF7DE;
    PIMASK64 := @IMASK64;
    // (src and $F7DE) shr 1 + (dest and $F7DE) shr 1
    asm

    {source}
    mov EAX, pSrc
    mov EDX, PIMASK64
    mov ECX, pSrc
    db $0F,$6F,$00 /// movq mm0, [EAX]
    db $0F,$DB,$02 /// pand mm0, [EDX]
    db $0F,$71,$D0,$01 /// psrlw mm0,1
    db $0F,$7F,$01 /// movq [ECX], mm0

    {destination}
    mov EAX, pDest
    mov EDX, PIMASK64
    mov ECX, pDest
    db $0F,$6F,$00 /// movq mm0, [EAX]
    db $0F,$DB,$02 /// pand mm0, [EDX]
    db $0F,$71,$D0,$01 /// psrlw mm0,1
    db $0F,$7F,$01 /// movq [ECX], mm0


    {add them together and output to dest}
    mov EAX, pSrc
    mov EDX, pDest
    mov ECX, pDest
    db $0F,$6F,$00 /// movq mm0, [EAX]
    db $0F,$FD,$02 /// paddw mm0, [EDX]
    db $0F,$7F,$01 /// movq [ECX], mm0

    end;
    Dec(iY,4);
    pSrc := Pointer(Cardinal(pSrc) + ;
    pDest := Pointer(Cardinal(pDest) + ;
    end;
    end;


    [/pascal]

    EDIT: OK, this works for 50/50 effect, but I have the black background pixels bah... Need to find a way around it

    2ND EDIT: I have been thinking about this... Maybe I could change the mask? or use another mask to remove those $0000 pixels... (scratches head)
    http://www.c5software.co.uk (site is being developed at the moment)

  4. #4

    ASM

    Any idea how I can sort out the black background pixels? Normally they are taken care of with the Blit, but using this new routine I am blending the black pixels from the source with the destination image

    I was thinking about adding a mask maybe? Background is $0000 btw.
    http://www.c5software.co.uk (site is being developed at the moment)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL