Post Reply 
(16C) WSIZE? Determine word size
03-30-2019, 09:27 PM
Post: #1
(16C) WSIZE? Determine word size
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

Cui Bono?
Find all posts by this user
Quote this message in a reply
03-31-2019, 01:45 AM (This post was last modified: 03-31-2019 03:30 PM by mfleming.)
Post: #2
RE: (16C) WSIZE? Determine word size
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!

Cui Bono?
Find all posts by this user
Quote this message in a reply
03-31-2019, 02:36 PM
Post: #3
RE: (16C) WSIZE? Determine word size
ah! yes, that's very nice Smile

thanks for that.

Cambridge, UK
41CL, 12C, DM15/16, 71B, DM42, 30b (WP 34S), 17B, 28S, 48GX, 50g, 50g (newRPL), Prime G2
various Casio, Rockwell 18R :)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)