Skip to content
John Kerl edited this page Jan 29, 2022 · 5 revisions

Compiling

Code

  • In both 32 and 64 directories, ff2mathlib.c is the library; others (you can write your own) have main in them.

Using yamm

  • Install yamm which turns .mki files into .mk files.
  • cd 32 or cd 64
  • make mk -- will run yamm to turn .mki files into .mk files
  • make

Without yamm

  • gcc -DUNIX ff2mathlib.c ff2mathtest.c -o ff2mathtest
  • gcc -DUNIX ff2mathlib.c yourmain.c -o yourmain

Examples

  • cd 64
  • make mk
  • make

Addition, multiplication, division tables

Using default modulus 0x13 of degree 4:

$ ff2mathtest
+
0 1 2 3 4 5 6 7 8 9 a b c d e f
1 0 3 2 5 4 7 6 9 8 b a d c f e
2 3 0 1 6 7 4 5 a b 8 9 e f c d
3 2 1 0 7 6 5 4 b a 9 8 f e d c
4 5 6 7 0 1 2 3 c d e f 8 9 a b
5 4 7 6 1 0 3 2 d c f e 9 8 b a
6 7 4 5 2 3 0 1 e f c d a b 8 9
7 6 5 4 3 2 1 0 f e d c b a 9 8
8 9 a b c d e f 0 1 2 3 4 5 6 7
9 8 b a d c f e 1 0 3 2 5 4 7 6
a b 8 9 e f c d 2 3 0 1 6 7 4 5
b a 9 8 f e d c 3 2 1 0 7 6 5 4
c d e f 8 9 a b 4 5 6 7 0 1 2 3
d c f e 9 8 b a 5 4 7 6 1 0 3 2
e f c d a b 8 9 6 7 4 5 2 3 0 1
f e d c b a 9 8 7 6 5 4 3 2 1 0

*
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
0 2 4 6 8 a c e 3 1 7 5 b 9 f d
0 3 6 5 c f a 9 b 8 d e 7 4 1 2
0 4 8 c 3 7 b f 6 2 e a 5 1 d 9
0 5 a f 7 2 d 8 e b 4 1 9 c 3 6
0 6 c a b d 7 1 5 3 9 f e 8 2 4
0 7 e 9 f 8 1 6 d a 3 4 2 5 c b
0 8 3 b 6 e 5 d c 4 f 7 a 2 9 1
0 9 1 8 2 b 3 a 4 d 5 c 6 f 7 e
0 a 7 d e 4 9 3 f 5 8 2 1 b 6 c
0 b 5 e a 1 f 4 7 c 2 9 d 6 8 3
0 c b 7 5 9 e 2 a 6 1 d f 3 4 8
0 d 9 4 1 c 8 5 2 f b 6 3 e a 7
0 e f 1 d 3 2 c 9 7 6 8 4 a b 5
0 f d 2 9 6 4 b 1 e c 3 8 7 5 a

/
 1 9 e d b 7 6 f 2 c 5 a 4 3 8
 2 1 f 9 5 e c d 4 b a 7 8 6 3
 3 8 1 4 e 9 a 2 6 7 f d c 5 b
 4 2 d 1 a f b 9 8 5 7 e 3 c 6
 5 b 3 c 1 8 d 6 a 9 2 4 7 f e
 6 3 2 8 f 1 7 4 c e d 9 b a 5
 7 a c 5 4 6 1 b e 2 8 3 f 9 d
 8 4 9 2 7 d 5 1 3 a e f 6 b c
 9 d 7 f c a 3 e 1 6 b 5 2 8 4
 a 5 6 b 2 3 9 c 7 1 4 8 e d f
 b c 8 6 9 4 f 3 5 d 1 2 a e 7
 c 6 4 3 d 2 e 8 b f 9 1 5 7 a
 d f a e 6 5 8 7 9 3 c b 1 4 2
 e 7 b a 8 c 2 5 f 4 3 6 d 1 9
 f e 5 7 3 b 4 a d 8 6 c 9 2 1

Add, multiply, divide

$ iff2mathop
a + b = 1
a * b = 2
a / b = 4
$ iff2mathop deadbeef cafefeed 6d3d0ec441738ff3 64
deadbeef + cafefeed = 14534002
deadbeef * cafefeed = 5fff3cac4db5e98b
deadbeef / cafefeed = 1c37e0ce43da1c4d

Step a generator

Following https://exegetotrope.blogspot.com/2013/01/cyclic-random-number-generation-using.html

See also code comments within iff2stepgen.c.

$ ./iff2stepgen 6d3d0ec441738ff3 3 64 1000 20
e58b2205aa541ae6
43a068cabf8fa0d9
c4e0b95fc090e16b
201cc52400c2ac4e
60254f6c0147f4d2
a06fd1b403c81d76
8d8d7c18452ba869
fbaa8aec8e0f7748
61c291f1d362162b
a247b21275a63a7d
8bf5d8f2df99c174
f12367d321d9cc6f
7e58a6b12319db42
82e9ebd3652a6dc6
ea0732b1ee0d39b9
533459167364c538
f55ceb3a95ad4f48
72d8338bff845e2b
9768549c008ce27d
d485f36040e6a974