How it works

The Instruction operation "bitwise" can be used to work integer arithmetic using common mathematical expression handling (also known as 'infix' notation). The integers are expected to be in hexadecimal, and can be any length whatsoever. (Compare this with eg the arithmetic operation, where numbers are limited to about 7 bytes in size). So an entire file that has been hex-encoded may be treated as a single integer. This is mainly useful for cryptographic work.

The numbers in bitwise are treated as base 16 / hexadecimal both for inputs and outputs. They do not need to be prefixed with an 0x. Likewise, all calculations and numbers are treated as using integers (whole numbers) at all times.

"Bitwise" Examples

Example 1: Basic A simple expression

The example below shows how the 'name' attribute is used for variable substitution. Results are in hexadecimal!

<instruction operation="bitwise">
	<input value="(x+y)*3-2" />
	<input name="x" value="4" />
	<input name="y" value="3" />
</instruction>
13

Here is a list of operators that the arithemetic expression handler understands:

  1. * (multiply)
  2. + (add)
  3. - (subtract/unary minus)
  4. / (divide)
  5. \ (quotient)
  6. % (modulo)

Here is a list of functions that the arithemetic expression handler understands, that take 2 parameters:

  1. max() maximum function
  2. min() minimum function
  3. xor() (bitwise exclusive or function)
  4. and() (bitwise and function)
  5. or() (bitwise or function)
<instruction operation="bitwise" note="example using 2 parameter functions.">
	<input value="and(max(pow(x,y),pow(y,x)),0x33)" />
	<input name="x" value="4" />
	<input name="y" value="3" />
</instruction>
11

Here is a list of functions that the arithemetic expression handler understands, that take 2 parameters, the second of which must not be too big a number (about 18 million trillion)!

  1. pow() power function
  2. shl() (bitwise shift left by so many bits.) shr() (bitwise shift right by so many bits.)
<instruction operation="bitwise" note="example using 2 parameter functions.">
	<input value="pow(shl(y,x),shr(z,x))" />
	<input name="x" value="4" />
	<input name="y" value="3" />
	<input name="z" value="55" />
</instruction>
F300000

Here is a list of functions that the arithemetic expression handler understands, that take 1 parameter:

  1. not (bitwise not function)
  2. abs (absolute function)
<instruction operation="bitwise" note="example using 1 parameter functions.">
	<input value="not(abs(x))" />
	<input name="x" value="-4" />
</instruction>
-5

Here is a list of functions that the bitwise expression handler understands, that take 3 parameters:

  1. rol (rotate bits left function with wordsize)
  2. ror (rotate bits right function with wordsize)

Note that any bits outside of the word length are not touched!

<instruction operation="bitwise" note="example using 3 parameter functions.">
	<input value="rol(x,1,2)" />
	<input name="x" value="5555555555555555555555555555555555555555" />
</instruction>
5555555555555555555555555555555555555556



Last Modified: Thu, 15 Jan 2015