rayzor

annotate src/swapbuf.asm @ 22:5380ff64e83f

minor changes from dos, and line endings cleanup
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 02 May 2014 14:32:58 +0300
parents 235c8b764c0b
children
rev   line source
nuclear@22 1 ; vim:set ft=nasm:
nuclear@22 2 segment code use32
nuclear@22 3
nuclear@22 4 ; void swap_buffers_asm(void *dest, void *src, int xsz, int ysz, int bpp)
nuclear@22 5 ; dest -> eax
nuclear@22 6 ; src -> edx
nuclear@22 7 ; xsz -> ebx
nuclear@22 8 ; ysz -> ecx
nuclear@22 9 ; bpp -> [ebp + 8] (after pushing ebp)
nuclear@22 10 global swap_buffers_asm_
nuclear@22 11 swap_buffers_asm_:
nuclear@22 12 push ebp
nuclear@22 13 mov ebp, esp
nuclear@22 14
nuclear@22 15 mov edi, eax ; let's hold dest ptr in edi, frees up eax
nuclear@22 16 mov esi, edx ; let's hold src ptr in esi, frees up edx
nuclear@22 17 ; calculate pixel count -> ecx, frees up ebx
nuclear@22 18 mov eax, ebx
nuclear@22 19 mul ecx
nuclear@22 20 mov ecx, eax ; now ecx = xsz * ysz
nuclear@22 21
nuclear@22 22 mov eax, [ebp + 8] ; eax <- bpp
nuclear@22 23 cmp eax, 32
nuclear@22 24 je .bpp32
nuclear@22 25 cmp eax, 24
nuclear@22 26 je .bpp24
nuclear@22 27 cmp eax, 16
nuclear@22 28 je .bpp16
nuclear@22 29 ; invalid bpp, ignore
nuclear@22 30 jmp .done
nuclear@22 31
nuclear@22 32 .bpp32: ; 32bit block transfer, no conversion
nuclear@22 33 rep movsd ; esi, edi, and ecx already loaded, just go...
nuclear@22 34 jmp .done
nuclear@22 35
nuclear@22 36 .bpp24: ; 32bpp -> 24bpp conversion (LSB-first), 1 byte overrun!
nuclear@22 37 movsd ; transfer a full 32bit chunk and inc esi,edi by 4
nuclear@22 38 dec edi ; backtrack dest one byte after last transfer
nuclear@22 39 dec ecx
nuclear@22 40 jnz .bpp24
nuclear@22 41 jmp .done
nuclear@22 42
nuclear@22 43 .bpp16: ; fuck 16bpp for now (TODO)
nuclear@22 44 .done:
nuclear@22 45 pop ebp
nuclear@22 46 ret