Log in

View Full Version : getting the AL of an int


The Keeper
June 13th, 2002, 12:05
My problem is, i have:

int i=(x-(z*0x64))/0x0A;

and i need just the AL of i,
i debugged and saw

eax = result of int i=(x-(z*0x64))/0x0A;

mov [ebp-300], eax

so i simply added to my code

__asm mov [ebp-0x300], al;

I wonder if there is a way to get only the al part of i, without having to use inline asm, there must be but i dunno if someone knows please tell me (c\c++)

thanks in advance.

naides
June 13th, 2002, 14:48
What about a bitwise and operation?

int j = i & 0xFF;

cyberheg
June 13th, 2002, 14:56
Either the bitwise AND which was posted above or use a pointer:

unsigned char *p;

p = (unsigned char *) &i;
store_var = *p;