cesurcelik
- 11th February 2006, 15:01
hi all.
i want to rotate 48 bits data with picbasic pro,but i don't know how to do that.
if someone helped me about it ,i'd appreciate it.
thank you in advance.
Bruce
- 11th February 2006, 18:10
You might want to run this through the MPLAB simulator to see how it works.
WordA VAR WORD BANK0 SYSTEM
WordB VAR WORD BANK0 SYSTEM
WordC VAR WORD BANK0 SYSTEM
Counts VAR BYTE BANK0 SYSTEM
GOTO Main ' jump to Main
' shifts bits left from WordA to WordB to WordC with highest bit
' in WordC being trashed.
ASM
Rotate macro
rlf WordA,f ; msb of lowbyte into carry
rlf WordA+1,f ; carry into lsb of highbyte, msb of highbyte into carry
rlf WordB,f ; carry into lsb of lowbyte, msb of lowbyte into carry
rlf WordB+1,f ; carry into lsb of highbyte, msb of highbyte into carry
rlf WordC,f ; carry into lsb of lowbyte, msb of lowbyte into carry
rlf WordC+1,f ; carry into lsb of highbyte, msb of highbyte into carry
bcf STATUS,C ; trash msb of WordC to prevent shifting into WordA lsb
decfsz Counts,f ; decrement shift counter
goto $-D'8' ; keep shifting until Counts = 0
endm
ENDASM
Main:
' starting 48-bit value = 1
WordA = 1 ' load low word
WordB = 0 ' load mid word
WordC = 0 ' load high word
Counts = 47 ' shift 48-bit value left by Counts
@ Rotate ' do it
' resulting 48-bit value = $800000000000
Here:
GOTO Here ' sit & spin after test
END
This can be expanded to work on any number of variables. The only real limitation is available RAM &
PBP system variables.
cesurcelik
- 13th February 2006, 09:05
@bruce
i thank you for your reply
it works perfectly
cesur
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.