| ??? 08/18/04 09:21 Read: times |
#76088 - RE: convert binary number to Hexa Responding to: ???'s previous message |
Now I come to think about it, rotating left will be more useful:
//
// Fast Long Nibble Rotate Left
//
// Author: Graham Cole
//
// Input: l - 32-bit word R4/R5/R6/R7.
//
// Output: l - 32-bit word R4/R5/R6/R7
//
// Function: l is rolled four bits to the left.
//
// Notes: Very useful for ASCII-Hexadecimal conversions etc.
//
#pragma ASM
$REGUSE _fast_long_nibble_rotate_left( A, R0, R4, R5, R6, R7 )
#pragma ENDASM
unsigned long int fast_long_nibble_rotate_left( unsigned long int l )
{
#pragma ASM
;
MOV A,PSW ;Get the base address of
ANL A,#0x18 ; the current register bank.
ORL A,#0x04 ;Point to register R4.
MOV R0,A ;R0 is a pointer to R4.
;
;rotate value 4 bits left.
;
;Acc R4R5R6R7
;xx ABCDEFGH
XCH A,R7 ;GH ABCDEFxx
XCHD A,@R0 ;Gb AhCDEFxx - R0 points to R4
INC R0 ;
XCHD A,@R0 ;Gd AhCbEFxx - R0 points to R5
INC R0 ;
XCHD A,@R0 ;GF AhCbEdxx - R0 points to R6
SWAP A ;fg AhCbEdxx
XCH A,R6 ;Ed AhCbfgxx
SWAP A ;de AhCbfgxx
XCH A,R5 ;Cb Ahdefgxx
SWAP A ;bc Ahdefgxx
XCH A,R4 ;Ah bcdefgxx
SWAP A ;ha bcdefgxx
XCH A,R7 ;xx bcdefgha
#pragma ENDASM
return( l );
}
|
| Topic | Author | Date |
| convert binary number to Hexa | 01/01/70 00:00 | |
| RE: convert binary number to Hexa | 01/01/70 00:00 | |
| Presentation - not Conversion | 01/01/70 00:00 | |
| RE: convert binary number to Hexa | 01/01/70 00:00 | |
| RE: convert binary number to Hexa | 01/01/70 00:00 | |
RE: convert binary number to Hexa | 01/01/70 00:00 |



