Arithmetic shifting a double in PASM2?
bob_g4bby
Posts: 440
Hi,
I'm writing a driver in TAQOZ for the MS5611 air pressure sensor and the conversion of raw pressure to real units entails 58 bit precision - says the application guide. Being a newcomer to PASM2, I've written a pair of functions for arithmetic shift left and right of a 64 bit number by n places for the TAQOZ assembler:-
--- arithmetic shift signed double d1 right by n positions, result is d2 code D>> ( d1 n -- d2 ) .l1 sar b,#1 wc sar c,#1 djnz a,#l1 jmp #@DROP end --- arithmetic shift signed double d1 left by n positions, result is d2 code D<< ( d1 n -- d2 ) .l1 sal c,#1 wc sal b,#1 djnz a,#l1 jmp #@DROP end
However, neither is doing what I'd hoped for - can anyone see what I've done wrong or omitted please?
Comments
You need to shift the carry into the second register:
Shift arithmetic right:
Shift left (arithmetic and bitwise is the same):
Andy
Thank you Andy, those functions work.