| ??? 12/08/04 01:36 Read: times |
#82737 - Compact code Responding to: ???'s previous message |
The small code loop: as given by Erik was interesting. With a little thought assembly can be used to produce such tight codes. And as Craig pointed out it just needs a little bit of lateral thinking. While on this, I recently wrote a small code for rippling a LSB nibble through a 16 bit number by one place.
; LFTSHFT is for adjusting the TWS reading by one nibble to the left. Thus
; a value of "01 23" after this routine will be "12 30". This is to match
; FILLRAM routine handling the ADC value display. Call with R0 pointing to
; "01".
LFTSHFT: MOV A, @R0 ; 01
SWAP A ; 10
MOV @R0, A ; Save interim result of 10
DEC R0 ; Point to the Low byte
MOV A, @R0 ; 23
SWAP A ; 32
ANL A, #0FH ; 02
INC R0 ; Point to high byte again
ORL A, @R0 ; 12
MOV @R0, A ; Save to high byte
DEC R0 ; Point to low byte
MOV A, @R0 ; 23
SWAP A ; 32
ANL A, #0F0H ; 30
MOV @R0, A
RET ; Hi byte = 12; Low Byte = 30
OK the above code is based on the obvious method - but will obviously more cumbersome for larger number of bits. Wonder if it can be made more "tighter". Raghu |
| Topic | Author | Date |
| 24bit /8bit long division | 01/01/70 00:00 | |
| 24bit /8bit long division | 01/01/70 00:00 | |
| How about rotate left? | 01/01/70 00:00 | |
| multibyte rotate | 01/01/70 00:00 | |
| Compact code | 01/01/70 00:00 | |
Rotate in hardware. | 01/01/70 00:00 | |
| Yes, that's better | 01/01/70 00:00 | |
| Some other suggestions | 01/01/70 00:00 |



