alloc(newmem,2048,21AF2BB0000) 
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here

originalcode:
// DllCallAddress("uint:cdecl", DllStructGetPtr($tCodeBuffer), "ptr", DllStructGetPtr($tPixelData), "ptr", DllStructGetPtr($tStruct_ARGB), "int", $iPixels)
// ;64Bit! -> ;first 4 parameters will be saved in rcx,rdx,r8,r9
push rdi
push rsi
push rbx
push rbp

mov rsi,rcx // ;pointer to first pixel in memory from the bmp > address check $tPixelData
mov rdi,rdx // ;pointer to memory from struct                 > address save $tStruct_ARGB
mov rbx,r8 // ;amount of pixels                               > max pixel $iPixels

// mov rax,[rsi] // address pixel memory xy
loop1:

cmp byte ptr [rdi+10],0 // count pixel < 0+1 exit loop
JA if_pixel01xy
add [rdi+0],1 // 0 count pixel x y
add [rdi+8],1 // count pixex x + 1
cmp byte ptr [rdi+0],4 // count pixel max x > 4-1
JB if_pixel01xy
    add rsi,999*1 // +999*1 = pixel y + 1
    sub rsi,888*1 // -4*4 = pixel x - 4 >  default x > 888*1 de lay 8 bytes
mov [rdi+0],0 // reset count pixel x y
add [rdi+C],1 // count pixex y + 1
if_pixel01xy:

cmp byte ptr [rsi+0],77 // pixel xy Opt1 > Opt2 0xFF0000 0x70
JNAE if01
cmp byte ptr [rsi+0],99 // pixel xy Opt1 < Opt2 0xFF0000 0xFF
JNBE if01
cmp byte ptr [rsi+1],77 // pixel xy Opt1 > Opt2 0x00FF00 0x70
JNAE if01
cmp byte ptr [rsi+1],99 // pixel xy Opt1 < Opt2 0x00FF00 0xFF
JNBE if01
cmp byte ptr [rsi+2],77 // pixel xy Opt1 > Opt2 0x0000FF 0x70
JNAE if01
cmp byte ptr [rsi+2],99 // pixel xy Opt1 < Opt2 0x0000FF 0xFF
JNBE if01

cmp byte ptr [rdi+10],0 // count pixel < 0+1 exit loop
JA exit_loop01
add [rdi+10],1 // 0 count pixel find
//mov rax,[rsi+0]
//mov [rdi+14],rax // get color
cmp byte ptr [rdi+10],1 // count pixel > 0 = 1 exit loop
JB exit_loop01
mov rbx,1 // exit loop
exit_loop01:

if01:
add rsi,4*1 // +4*1 =  pixel x + 1
sub rbx,1 // for loop -1 = 0 exit loop
JA loop1a

// [rdi+8] > x 14
// [rdi+C] > y 3
// [rdi+0],4 // count pixel max = 4
// y3 * max 4 = 12 > x 14-12 > x = 2 y = 3

// [rdi+0] = count x y pixel
// [rdi+8] = count pixex x + 1
// [rdi+C] = count pixex y + 1
// [rdi+10] = count pixel color
// [rdi+14] = get pixel color

pop rbp
pop rbx
pop rsi
pop rdi
ret

exit:
jmp returnhere

21AF2BB0000:
jmp newmem
nop
returnhere:

