![]() |
Forum Index : Microcontroller and PC projects : bit swap in byte
![]() ![]() |
|||||
Author | Message | ||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1102 |
Again: your solution is elegant. I think we will lost the speed advantage if we do the operation 8 times. 8 * 15us would be 120us (or more) vs. 30us for the CSub solution. Kind regards Michael EDIT: Anyway a good solution for Gerald! ![]() Edited 2022-07-28 04:30 by twofingers |
||||
ville56 Regular Member ![]() Joined: 08/06/2022 Location: AustriaPosts: 67 |
indeed it is refreshing for my mind to see all the different solutions. It leads me away from my old and small paths of thinking for this particular problem. This forum is really world class with all its potential. @twofingers: thanks for the cookbook to csub :-), i really appreciate it. Have to dive into it deeper, but at the moment i have to spend some time on servicing my motorbike for my annual statutorial inspection. Regards and thanks, Gerald                                  73 de OE1HGA, Gerald |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1102 |
@Gerald Viel Glück beim TÜV! ![]() |
||||
ville56 Regular Member ![]() Joined: 08/06/2022 Location: AustriaPosts: 67 |
Danke! Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 73 de OE1HGA, Gerald |
||||
twofingers Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1102 |
Just to complete this topic. A version for 8-bits reversing: 8Bitorderreverse.zip On a 378MHz PicoMite reversing the bit order for a Byte takes 12us. Regards Michael edit: Just to clarify: I think Peter's solution is the better one. Edited 2022-07-28 22:24 by twofingers |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 304 |
Here's one way: 10 INPUT "Enter a number:",n:print 20 h$=right$("0000"+hex$(n),4) 30 PRINT h$ 40 h$=right$(h$,2)+left$(h$,2) 50 nr=val("&h"+h$) 60 PRINT h$ 70 PRINT nr |
||||
![]() ![]() |
![]() |