Etikettarkiv: c

Free Programming Books

DSC_5834 RKRM set of books
Amiga Books

Free Programming Books covers most of the today programming languages and many you did never take a look at (or need) from the past.  All books are ebooks free for download and may be an assistance to you if you are learning a new language or just want to brush up your knowledge for some reason.

There are 338 books in this collection so you will have plenty to read for a while now!

Operating Systems I can not forget

Computer Sweden is running an article about nine operating systems that everyone who was a part of the personal computer revolution can not forget about.

TeleNova Compis
TeleNova Compis

First out is CP/M. I loved this OS, I was the first OS and micro computer I ever got in touch with in 7th grade in school. The actual machine was a Compis Telenova computer that was equipped with an Intel 80186 CPU running at 8 MHz. Later versions such as Compis II could also run MS-DOS early versions. The computer was ordered and sponsored by the state own telephone company, ”Televerket”, and was aimed to be an educational computer that could be used in schools. It was cheaper than IBM PC machines at the time and it had graphics that was way beyond what most other computers had. The original COMPIS was monochrome (green or amber) but there later came colour versions with upgrader 16 colour graphic cards. The entire machine was developed by a Swedish company Teli and the school where I was attending my 7th to 9th grade used these machines.

I learned my firs programming skills on these machines, they were equipped with a language called COMAL which was a cross between a traditional BASIC interpreter but with several add-ons borrowed from Pascal, making it a language with modern loop constructs and everything needed to teach basic programming to students. Actually a quite good language in itself – it even had built-in commands to do ”turtle graphics” a special way of programming graphics where you move a a virtual pen around a drawing board with command such att GOTO 320,480; PENDOWN; DRAWLINE -100,0; PENUP; GOTO 0,480; and so on. How many computers in 1985 could do graphics with 1280×800 pixels (monochrome) or 640×400 in colour? I later got a Commodore VIC-20 computer at home and I found it rather marvellous how different they were. I tried my best writing essays and stuff on the Commodore but it just screamed ”play games” and later ”learn how to make games”…

Then came the IBM PC machines with DOS. It was felt that DOS was a superior operating system, I don’t think it was technically better than CP/M and actually suffered from some of the same limitations and had even some drawbacks CP/M lacked. But it was picked up by IBM from a small upstart company called Microsoft and the rest is history. When I attended college the IBM machines started become increasingly popular and the PS/2 was the choice of most schools. During this time I used a Commodore 128D at home at this time, I had learned 6502 assembler and could do quite a bit of ”demos” programming. Techniques such as using interrupts for timing, programming the VIC and SID chips and so on was mastered during these days :)

Other people used Mac OS at this time, but I never had a Mac, liked them or came anywhere around where they where being used. In fact I think the only one in the school was in the music lab for the musicians to use as a MIDI controller.

Amiga OS 1.3 Workbench
Amiga OS 1.3 Workbench

Then came the Amiga. The revolution was complete. A proper, unix influenced OS, that was really powerful, came with enough tools to make a difference out of the box and friendly to be programmed and used, borrowing menu systems and ideas from both X-Windows System and Mac OS ”System” together with a powerful handling of various devices and a great shell command line interface. I loved my Amiga, I used it way into 1996 even though I had a 386SX 25 with 20 MB of memory (quite a lot in those days) but the Amiga was always the number one computer. I did BASIC and 68000 assembly language programming on it and this was the place where I learned C. The great language that is still my favourite among programming languages, one of the most versatile and useful languages. Hated and loved equally but never disputed as a very useful language I hacked away on a Lattice 3.1 compiler on the Amiga.

Then there was OS/2, a joint venture between IBM and Microsoft that went belly-up and the last thing I ever saw from it was in Arlanda airport around 1996 when they used it on the gate computers. MS Windows had already taken over completely, even at version 3.11 it was becoming the standard for the IBM PC computers. I never used any of those myself, I was already into Linux which was running on my 386 alongside with Amiga OS on the Amiga 500 I loved so dearly.

Linux of course! What a revolution! My first distribution was a bunch of diskettes called ”Slackware” which I installed. Finally you could hack your own kernel, I managed to run this on various architectures including the strange Micro-Channel Architecture that IBM put into some computers just to make a mess of the IDE interface, and I have been using Linux for most serious tasks ever since together with Windows 95 and now Windows XP. Not doing Vista just yet…


Recently I needed a fast an reliable hash function with good statistics on distribution and I came across what is commonly known as the FNV-hash function. FNV is short for Fowler / Noll / Vo the last names of the three most prominent people contributing to the hashing function.

Basically the FNV algorithm is a very simple one but it is effective and yields astonishingly well differentiated hashes. It has been used in many different codes and both the algoritm itself and a standard source coude has been released into the public domain.

Pseudo code

hash = offset_basis
for each octet_of_data to be hashed
	hash = hash * FNV_prime
	hash = hash xor octet_of_data
return has

The above is called the FNV-1 algorithm. If the multiplication and the XOR change place we get a variant called the FNV-1a which is very similar in all aspects of the first one. I decided to implement both and hash both as 32 bit numbers and then put them together into one 64 bit number creating a very fast and even spread of hashed numbers.

Prime and offsets

32 bit
Prime: 16777619 offset: 2166136261
64 bit
Prime: 1099511628211 offset: 14695981039346656037

Here is a page on FNV that is a good source of information.

NSA has released Cryptol

 Cryptol is a language used to specify, implement, test and verify cryptographical algorithms. I have just taken a first glance at it and it seems really competent. All cryptography buffs out there should rejoice over this tool.

Cryptol can further ”compile” your cryptographic algorithms into languages such as VHDL, C and Haskell. You may download a trial version for non-commercial uses from the galois site.