|
> asm mov ax ,[ WORD PTR rndval ] > asm mov dx ,[ WORD PTR rndval +2] > asm mov bx , ax > asm dec bl > asm mov [ BYTE PTR y ], bl // low 8 bits - 1 = y > asm mov bx , ax > asm mov cx , dx > asm mov [ BYTE PTR x ], ah // next 9 bits = x > asm mov [ BYTE PTR x +1] , dl I don't understand the need for the second asm mov bx , ax : BX is not used afterwards. Same for CX, it is never used. > uint32_t rndval = 1; > uint16_t x,y; > do > { > y = rndval & 0x00F; // Y = low 8 bits > x = rndval & 0x1F0; // X = High 9 bits Er... no, if you do that, you only get the lowest 4 bits in y, and then you only get 5 bits in x (and not the right ones, of course). It should be: y = rndval & 0x000000FF; // Y = low 8 bits
And then you have a 'problem' for x, because you must shift it right, otherwise it doesn't fit in a 16-bit variable: x = rndval & 0x0001FF00; // X = bits 8 to... 16 > 15, irk
So you should just do : x = rndval >> 8; // X = bits 8 to 17, in their right place
|