given short example below, there way reduce amount of registers used in code between [x1] , [x2]?
i read input pina , generate output portb according logic table. straightforward way me, seems kind of roundabout. there more elegant way not aware of?
loop: ;set masks inputpins [x1] ldi r17, 0b00000010 ldi r18, 0b00000100 ;read input pina in r16, pina ;apply masks , normalize , r17, r16 lsl r17 , r18, r16 lsl r18 lsl r18 ;start actual bitwise operations e.g [x2] mov r16, r17 xor r16, r18 , r16, r17 ... ... out portb, r16 rjmp loop
note not interested in perfomance (space, speed) in reducing amount of mask , shift operations introduce (sloppy / nasty) errors on bigger scale.
also note not sure if codereview.stackechange more appropiate place question.
i don't think can cut down on number of registers used in particular case because looks want keep contents of r16
pristine.
if didn't need that, use andi
instruction load bitmasks immediate data.
Comments
Post a Comment