Speed contest: Fast code desired, space is no object. Task: Make UP look like Down by rotating all the bits in a byte. Input in TEMP, output in TEMP2 or for bonus points, in TEMP, such that Input: 7,6,5,4,3,2,1,0 10101110 or AE Routine happens, then Output: 0,1,2,3,4,5,6,7 01110101 or 75 The obvious solution is to clear the output and set the bits with SBRC like this: ; ;************************************************************************************* ; ;Bit swap end for end. ; Untwist: push TEMP2 ; clr TEMP2 ; sbrc TEMP,0 ; sbr TEMP2,1<<7 ; sbrc TEMP,1 ; sbr TEMP2,1<<6 ; sbrc TEMP,2 ; sbr TEMP2,1<<5 ; sbrc TEMP,3 ; sbr TEMP2,1<<4 ; sbrc TEMP,4 ; sbr TEMP2,1<<3 ; sbrc TEMP,5 ; sbr TEMP2,1<<2 ; sbrc TEMP,6 ; sbr TEMP2,1<<1 ; sbrc TEMP,7 ; sbr TEMP2,1<<0 ; mov TEMP,TEMP2 ; pop TEMP2 ret ;
Message
Challenge
2005-06-07 by Dave VanHorn
Attachments
- No local attachments were found for this message.