Mail Archives: djgpp/1998/10/05/10:18:53
On Mon, 5 Oct 1998, Craig Rothwell wrote:
> how can I join 2 sets of binary
> to make one?
>
> eg:
>
> turn '11111111' and '00000000'
> (as 2 variables)
>
> into '1111111100000000'? (as one
> variable)
Shift the first one left by 8 bits, then add on the second:
(a << 8) + b
> A bit like using the Z80's HL
> register, where you could treat
> each variable seprate but also
> as one big number.
The 80x86 have that sort of system too. Assume `a' and `b' are
global or static 32-bit integer variables:
xorl %eax, %eax
movb _a, %ah
movb _b, %al
movl %eax, _a
That puts the bottom byte of `a' into the second byte of `a' and
the bottom byte of `b' into the bottom byte of `a'. The rest of
`a' is zeroed.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
xu do tavla fo la lojban -- http://xiron.pc.helsinki.fi/lojban/lojban.html
- Raw text -