Re: A85: Accessing bits


[Prev][Next][Index][Thread]

Re: A85: Accessing bits




At 18:58 1998-05-11 -0400, you wrote:
>
>Let's say I have a byte stored in my ZShell program like this:
>
>SomeByte:
>.db %10110110
>
>How would I split that number up to this:
>10-11-01-10
>(Four new binary numbers ranging from 0 to 3)

 ld a,(SomeByte)
 ld hl,split
 ld b,4
SplitByte:
 rlca
 rlca
 push af
 and 3
 ld (hl),a
 inc hl
 pop af
 djnz SplitByte

would store the splitted byte in split - (split+3)
each a value between 0 and 3. (split)=left, (split+1)=right etc

--
Real name: Jimmy Mårdell                "can't go mucking with a 'void *'"
IRC......: Yarin                                // Apple's MPW C compiler
Email....: mailto:yarin@acc.umu.se        
Homepage.: http://www.algonet.se/~mja/


Follow-Ups: References: