BBC BASIC for Windows
Programming >> Assembly Language Programming >> Testing if MSB of 32-bit word is < 255 http://bb4w.conforums.com/index.cgi?board=assembler&action=display&num=1294904598 Testing if MSB of 32-bit word is < 255
Post by David Williams on Jan 13th, 2011, 06:43am
This is probably embarassingly trivial.
I have a 32-bit ARGB pixel stored in a register, EDX:
EDX = &AaRrGgBb
I'd like to test if the MSB (&Aa) is less than 255 without having to copy (preserve) EDX then shift it:
Code:
mov ebx, edx ; copy EDX
shr edx, 24 ; shift alpha value to range 0 - 255
cmp edx, &FF ; is alpha < 255 ?
jl blendpxl ; branch if so...
Incidentally, I expected cmp dl, &FF to be equivalent (in this case) to cmp edx, &FF, and it's the not realising this fact that resulted in over an hour of frustrating bug-hunting in the early hours of this morn!
Regards, David.
Re: Testing if MSB of 32-bit word is < 255
Post by admin on Jan 13th, 2011, 10:13am
I have a 32-bit ARGB pixel stored in a register, EDX: EDX = &AaRrGgBb I'd like to test if the MSB (&Aa) is less than 255 without having to copy (preserve) EDX then shift it:
This is what I'd do:
Code:
cmp edx,&FF000000
jb MSbytelessthan255
Richard. Re: Testing if MSB of 32-bit word is < 255
Post by David Williams on Jan 13th, 2011, 10:58am