The following warnings occurred:
Warning [2] Undefined array key 57793 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 57793 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





Bit fiddling on the HP33s



#2

Bit fiddling on the HP33s

One of the omissions on the 33s is bit fiddling commands - and, or, not. This is odd, since numbers in bases 16, 8, and 2 can be entered and used. So, I decided to fix this.

The routines shown here work on 32 bit unsigned integers, though any number of bits (up to 35) can be used. The method used is to get the corresponding bits of the 2 words to be operated upon, get a value from 0 to 3, and use that as a lookup in a 4 bit table. Separate tables are used for and, or, and not. Any 4 bit table can be used.

The routine uses the integer divide and remainder operations on the 33s; I do not know if they are on the 32sii.

The routine uses only integer values, so it can be run in hex, oct, or bin mode. However, you have to be in decimal mode when entering the "y^x" command.

The code uses lbl H to return the number of bits to process.

The registers used are:

V: First operand
U: Second operand
T: 4 bit table
S: 2^k for k from 31 to 0
R: Result

Usage:

And: V U xeq A
Or: V U xeq O
Not: U xeq N

Result in X, U in Y, and V in Z (so you can roll down to get parameters)

General; V U table xeq B

Code: (comments indicated by "//")

And:
LBL A
8 // decimal - 1000 binary
gto B

Or:
LBL O
14 // decimal - 1110 binary
gto B

Not:
LBL N
5 // decimal - 0101 binary
gto B

Number of bits:
LBL H
16 // or 8 or 32 or ...
rtn

Bit fiddler:

LBL B
sto T // the 4 bit table
Rv // roll down
abs sto U // make it unsigned
Rv abs sto V // got the operands and table
2 xeq H 1 - y^x sto S // bit extractor
0 sto R // the eventual result

LBL C // start of the loop
rcl V rcl S int/ // integer part of V/2^k
2 rmdr 2 * // 2 times the bit
rcl U rcl S int/ 2 rmdr // same for U
+ // 2*v_bit + u_bit
2 x<>y y^x // 2^u_v value
rcl T x<>y int/ // x<>y could be saved if T loaded earlier
2 rmdr // that's the bit
rcl* S sto+ R // scale up and store
rcl S 2 int/ sto S // get next lower power of 2
x>0? gto C // if anything there, continue
rcl V rcl U rcl R // load inputs and output
rtn // done

Possible improvements/enhancements:

1) Get 2 bits at a time, and use a 16-bit table. This would cut the running time by about 50% - it is now about 4 seconds on a 33s.

2) have 3 or more parameters - an arbitrary truth table of up to 5 parameters (n parameters takes 2^n bits) could be handeled.

My usual statement: All comments and suggestions will be considered.

One nice thing about the 33s - you can't run out of program space - you will run out of labels first!

Martin Cohen
5/4/04

Note added later: I have written a 2-bit version, as mentioned in (1) above. If anyone is interested, I can post it.


Possibly Related Threads…
Thread Author Replies Views Last Post
  bit manips on WP 34S Kiyoshi Akima 8 2,380 10-06-2013, 06:25 AM
Last Post: Paul Dale
  Where to the 32-bit version of User Code Utiltiy for HP-41 ? Olivier (Wa) 2 1,470 09-26-2013, 01:55 AM
Last Post: Olivier (Wa)
  OT: Simulating a TI calculator with crazy 11-bit opcodes Egan Ford 8 2,580 08-13-2013, 12:06 AM
Last Post: Paul Dale
  WP-34S Overlay - making it a bit more permanent? Marcel Samek 1 1,081 07-05-2013, 09:02 PM
Last Post: htom trites jr
  HP-35--then and a wee bit later Matt Agajanian 1 886 04-12-2012, 07:52 AM
Last Post: Jeff O.
  WP34 S: Fonts (a bit OT) Marcus von Cube, Germany 18 4,326 02-24-2012, 11:07 AM
Last Post: Luiz C. Vieira (Brazil)
  32-bit MCODE tool chain for the HP41 incl. D41 now MichaelG 4 1,941 02-12-2012, 08:57 PM
Last Post: Kerem Kapkin (Silicon Valley, CA)
  32-bit version of User Code Utiltiy for HP-41 MichaelG 4 1,675 02-08-2012, 07:12 AM
Last Post: MichaelG
  Interest in 32-bit version of User Code Utiltiy for HP-41 MichaelG 16 3,825 01-30-2012, 02:01 PM
Last Post: MichaelG
  HP-41 MCode Assembler/Linker 32-bit version MichaelG 19 4,615 01-22-2012, 12:44 PM
Last Post: MichaelG

Forum Jump: