04-25-2020, 12:39 PM
Post: #1
 Eddie W. Shore Senior Member Posts: 1,237 Joined: Dec 2013
The programs NOTBIT, NAND, NOR, and IMPL are four advanced Boolean functions that work on Binary Numbers. You designate a bit size, up to 35, on each of these functions. There is no signed bit in these programs. Results are stored in the Alpha Register while the decimal equivalent is stored in the X register.

HP 42S/DM42/Free 42 Program: NOTBIT
Code:
 00 { 57-Byte Prgm } 01▸LBL "NOTBIT" 02 "BIT SIZE?" 03 PROMPT 04 STO 00 05 BINM 06 "BIN?" 07 PROMPT 08 STO 01 09 DECM 10 2 11 RCL 00 12 Y↑X 13 X<>Y 14 BASE- 15 1 16 BASE- 17 BINM 18 "NOT: " 19 ARCL ST X 20 AVIEW 21 EXITALL 22 .END.

Example:

NOT 11011, bit size: 8

Result:
NOT: 11100100

HP 42S/DM42/Free 42 Program: NAND

a NAND b = NOT ( a AND b )
Code:
 00 { 67-Byte Prgm } 01▸LBL "NAND" 02 "BIT SIZE?" 03 PROMPT 04 STO 00 05 BINM 06 "BIN1?" 07 PROMPT 08 STO 01 09 "BIN2?" 10 PROMPT 11 STO 02 12 AND 13 DECM 14 2 15 RCL 00 16 Y↑X 17 X<>Y 18 BASE- 19 1 20 BASE- 21 BINM 22 "NAND: " 23 ARCL ST X 24 AVIEW 25 EXITALL 26 .END.

Example:

110011 NAND 111100, bit size: 8

Result:
NAND: 11001111

HP 42S/DM42/Free 42 Program: NOR

a NOR b = NOT ( a OR b )
Code:
 00 { 64-Byte Prgm } 01▸LBL "NOR" 02 "BIT SIZE" 03 PROMPT 04 STO 00 05 BINM 06 "BIN1?" 07 PROMPT 08 STO 01 09 "BIN2?" 10 PROMPT 11 STO 02 12 OR 13 DECM 14 2 15 RCL 00 16 Y↑X 17 X<>Y 18 BASE- 19 1 20 BASE- 21 BINM 22 "NOR: " 23 ARCL ST X 24 AVIEW 25 EXITALL 26 .END.

Example:

110011 NOR 111100, bit size: 8

Result:
NOR: 11000000

HP 42S/DM42/Free 42 Program: IMPL

IMPL (Implication): a → b = (NOT a) OR b
Code:
 00 { 66-Byte Prgm } 01▸LBL "IMPL" 02 "BIT SIZE?" 03 PROMPT 04 STO 00 05 BINM 06 "BIN1?" 07 PROMPT 08 STO 01 09 DECM 10 2 11 RCL 00 12 Y↑X 13 X<>Y 14 BASE- 15 1 16 BASE- 17 BINM 18 "BIN2?" 19 PROMPT 20 STO 02 21 OR 22 "A→B: " 23 ARCL ST X 24 AVIEW 25 EXITALL 26 .END.

Example:

110011 IMPL 111100, bit size: 8

Result:
IMPL: 11111100

Source:

John W. Harris and Horst Stocker Handbook of Mathematics and Computation Science Springer: New York, NY. 2006. ISBN 978-0-387-94746-4

04-25-2020, 04:03 PM
Post: #2
 Nihotte(lma) Member Posts: 70 Joined: Mar 2020
(04-25-2020 12:39 PM)Eddie W. Shore Wrote:  The programs NOTBIT, NAND, NOR, and IMPL are four advanced Boolean functions that work on Binary Numbers. You designate a bit size, up to 35, on each of these functions. There is no signed bit in these programs. Results are stored in the Alpha Register while the decimal equivalent is stored in the X register.

Thanks Eddie W. Shore,

I'm interesting to know : are you writing some programmable robot or other compiler ?
04-25-2020, 06:13 PM
Post: #3
 Eddie W. Shore Senior Member Posts: 1,237 Joined: Dec 2013