Hello, here I developed the code for Mirror / flipping 8 bpp.BMP image horizontally. Handle any width properly, not just a multiple of 4. Now I need to convert this code to do the same, but for 1 bpp. bmp (grayscale) using x86. The hard part is that I don’t know how to increase my bit, maybe someone can edit this code.
section .text
global mirrorbmp8
mirrorbmp8:
push ebp
mov ebp, esp
push ebx
push esi
push edi
mov ebx, [ebp+12] ;width - without padding
and ebx, 11b
je init ;checking if there is a padding
mov edi, 4
sub edi, ebx
add [ebp+12], edi ;width - with padding
init:
mov ebx, [ebp+16]
;calculating the distance between top&bottom pixel
dec ebx
mov eax, [ebp+12]
mul ebx
mov esi, eax
mov edi, [ebp+8] ;the first bottom pixel
mov edx, edi ;the first top pixel
mov eax, edi
add eax, esi
mov ecx, [ebp+12]
;register responsible for calc left columns
loop0:
push esi
mov esi, [ebp+12]
loop1:
mov bl, [edi] ;changing pixels
xchg bl, [eax]
mov [edi], bl
add edi, esi ;next pixel in this column
sub eax, esi
cmp edi, eax
jl loop1
inc edx ;next bottom pixel
mov edi, edx
mov eax, edi ;next top pixel
pop esi
add eax, esi
dec ecx ;decrement number of columns left
jnz loop0 ;was that the last column?
end:
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
Any help would be appreciated. Thanks in advance:)
ps, if I can make this version, then I will have to convert all the code for version x86-64, and any hints in this regard will also be useful.