HP Forums
(16C) WSIZE? Determine word size - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (16C) WSIZE? Determine word size (/thread-12710.html)



(16C) WSIZE? Determine word size - mfleming - 03-30-2019 09:27 PM

The 16C can set the word size from 1 to 64 bits but has no way to retrieve the value of that setting. So everyone ends up shifting a 1 leftward across a word until the carry is set. Here is a simple routine that only affects the X register, to which is returned the current word size.

Code:

(from DM16C)
001  LBL A        | 43 22 A     WSIZE?
002  CLX          |    43 35    Don't disturb stack
003  STO I        |    44 32    Counter initial value
004  CLX          |    43 35    Don't disturb stack
005  1            |       1     Bit pattern to find word size
006  LBL 0        | 43 22 0
007  F? 4         | 43 6 4      Carry set?
008  GTO 1        |    22 1     Yes
009  SL           |    42 A     Shift bit across word into carry
010  ISZ          |    43 24    Increment word size counter
011  GTO 0        |    22 0
012  GTO 0        |    22 0
013  LBL 1        | 43 22 1
014  CF 4         | 43 5 4      Don't leave carry set
015  CLX          |    43 35    Don't disturb stack
016  RCL I        |    45 32    Recall word size
017  RTN          |    43 21



RE: (16C) WSIZE? Determine word size - mfleming - 03-31-2019 01:45 AM

I'm embarrassed to say I've managed to make a right turn by taking three lefts! As cdmackay's program comment reminded me, there's a much simpler way to get the word size.

Code:

LBL A    43 22 A
CLx      43 35   Zero
f NOT    42 30   All ones
g B#     43 7    How many?
RTN      43 21

NB: Replace "CLx" in the second line with "0" to preserve the content of the X register. This code is now a semi-permanent resident as LBL F in memory!


RE: (16C) WSIZE? Determine word size - cdmackay - 03-31-2019 02:36 PM

ah! yes, that's very nice Smile

thanks for that.