nopf
nopf (Numbers, Operators, Functions) is an interactive, command-line expression evaluator.
nopf can be useful if you work with hexadecimal often employing bit shifts and masks. It supports pretty formatting of some common x86/x64 register. It shows the results as 32-bit and 64-bit unsigned integer in decimal, octal, hexadecimal and binary radices.
nopf supports several built-in functions and variables. You can also define arbitrary variables as expressions and use them in the calculation of subsequent expressions.
Features
-
Performs separate integer and floating-point math for every operation.
-
Interactive mode with colored output.
-
Auto-completion on *nix platforms that support libreadline in interactive mode.
-
Support for user-defined constants.
-
Support for input and output in hex, oct, decimal and binary.
-
Bit shifts, alignment and other bitwise operations.
-
Pretty printing of some x86/amd64 registers with description of bits.
-
Unit of measure conversions for common units like pages to bytes, gigabits to bits etc.
-
Basic statistics like sum, avg, lcd, gcd.
License
nopf is free software published under the GNU Public License (v3). Contributions in the form of patches are welcome as long as they are compatible with this license.
Source code
Source code available at nopf’s GitHub repository.
Sample output
> avg(10, 12, 14, 0x18 + 0x120)
Bool: true (N)
Dec : 87 (U32) 87 (U64) 87 (N)
Hex : 0x00000057 (U32) 0x0000000000000057 (U64) 0x57 (N)
Oct : 000000127 (U32) 00000000000000127 (U64) 0127 (N)
Bin : 101 0111 (7)
> myvar = 60
Stored variable: 'myvar'
> min2sec(myvar)
Bool: true (N)
Dec : 3600 (U32) 3600 (U64) 3600 (N)
Hex : 0x00000e10 (U32) 0x0000000000000e10 (U64) 0xe10 (N)
Oct : 000007020 (U32) 00000000000007020 (U64) 07020 (N)
Bin : 1110 0001 0000 (12)
> efer 0xd01
efer:
0000 0000 0000 0000 0000 1101 0000 0001
│││ ││ │ │
│││ ││ │ └── SCE ( 0) *
│││ ││ └───────────── LME ( 8) *
│││ │└─────────────── LMA (10) *
│││ └──────────────── NXE (11) *
││└────────────────── SVME (12)
│└─────────────────── LMSLE (13)
└──────────────────── FFXSR (14)