Friday, 7 May 2010

My Latest Gadget: Altera MAX II

SLS ELT II development board with Altera MAX II

Here's my latest gadget, a SLS ELT II development board with Altera MAX II picked up for £1.20 on eBay :-) It provides 240 programmable logic elements and 8 kilobits of flash memory.  I haven't got anything planned for it yet apart from a crazy idea about evolving a logic array to solve a problem.  Have you got any great ideas for a project?

Monday, 3 May 2010

10 Alternative Monospace Fonts for Programmers

Recently I started to look for an alternative programming font after spending far too many hours staring at Courier New. I needed to find a free fixed-width font that's easy on the eye and clearly distinguishes between similar characters, e.g. O01Il.

Here's a quick round up of the best alternatives I found. Which programming font are you using? Did I miss your favourite?

Default Monospace Fonts


First let's take a look at the default fonts. The examples show the font at 12 point with subpixel rendering switched off:

Consolas



Consolas is a monospace programming font created for Microsoft by Lucas de Groot and ships with Windows Vista / Windows 7. Has a slashed zero and designed to look best with ClearType enabled.

Courier New



Courier New is perhaps the most familiar monospace font having been introduced in 1992 with Windows 3.1. Courier New is a serifed font designed by Adrian Frutiger and lacks a slashed zero.

Lucida Console



Lucida Console designed by Charles Bigelow and Kris Holmes is the default font for Windows Notepad and also lacks a slashed zero.

Monaco



Monaco is a sans-serif monospace font designed by Susan Kare and Kris Holmes and ships with Mac OS X. Includes a slashed zero.

Alternative Monospace Fonts


While some of the default fonts aren't too bad, we can do much better. Here are some great alternatives mostly designed with programmers in mind:

Anonymous Pro



Anonymous Pro is a programming font designed by Mark Simonson. The serifed font was influenced by Susan Lesch and David Lamkins' Anonymous 9. Very clear with plenty of white space and a slashed zero.

Bitstream Vera Sans Mono



Bitstream Vera Sans Mono is a sans-serif coding font designed by Jim Lyles from Bitstream. The zero is dotted and the bottom of the lower case l curls to the right.

DejaVu Sans Mono



DejaVu Sans Mono is extended from Bitstream Vera Sans Mono and supports a wider selection of characters. The clean sans-serif font ships with a number of Linux distributions.

Dina



Dina is a sans-serif programming font created by Jørgen Ibsen and is available in 8, 9 or 10 point. Has a slashed zero.

Droid Sans Mono



Droid Sans Mono was designed by Steve Matteson of Ascender Corporation. The sans-serif font is clear but lacking a slashed or dotted zero.

Envy Code R



Envy Code R is a clean sans-serif programming font designed by Damien Guard and includes a slashed zero.

Inconsolata



Inconsolata is a monospace programming font created by Raph Levien and inspired in part by Consolas. Has a slashed zero.

Monofur



Monofur is a quirky monospace font created by Tobias Benjamin Köhler. Includes a dotted zero and a curl on the lower case l.

Proggy Clean



Proggy Clean was designed by Tristan Grimmer and is available with either a dotted or slashed zero. Several variants of the Proggy font are available.

Triskweline



Triskweline is a clear monospace font created by Henning Koch. Lacks a slashed zero and only available in 10 point.

Sunday, 4 April 2010

Classic Home Computer Fonts

Anyone who owned a home computer in the 80's would have been intimately familiar with the character set. Although it was possible to redefine the font, it had to be loaded from cassette and was restricted to an 8×8 pixel grid. Love it or hate it, you were stuck with it.

Fortunately for anyone who misses their 8-bit computer a selection of classic fonts are available online. Here are a few of my favourites:

Amstrad CPC Font Amstrad CPC font

Atari Font Atari font

Commodore 64 font Commodore font

ZX Spectrum font ZX Spectrum font

Which home computers did you own and what did you love / hate about the font? :-)

Saturday, 20 March 2010

Threaded Interpretive Languages by R. G. Loeliger

Threaded Interpretive Languages by R. G. Loeliger
In Threaded Interpretive Languages, Loeliger explores the design and implementation of TILs in an individual quirky style.  Programs in a threaded language typically compiles to a list of subroutine calls or addresses. Loeliger focuses on Forth-like threaded languages and provides examples in Z80 assembly language.

After the standard introductory chapter the book gets straight down to the implementation details, first dealing with the design of the dictionary format, inner and outer interpreters.  This is followed by example code for the interpreters and assembly language definitions for 170 of the most common subroutines.

Later chapters investigate some common extensions to TILs including virtual memory and floating point numbers. A section is devoted to assemblers and includes code for a structured Z80 assembler.

Threaded Interpretive Languages contains the most in-depth examination of Forth internals I've seen. However the age of the books shows in the dialect of Forth used and the systems described. Despite this, I'd still recommend Threaded Interpretive Languages to anyone planning to implement a minimal Forth.

Sunday, 28 February 2010

Emulating the Manchester SSEM

display from my Manchester SSEM emulator
The Manchester Small-Scale Experimental Machine was the first computer to store programs in memory and was built at the University of Manchester in 1948 by Williams, Kilburn and Toothill.

The machine had 32 words of 32 bit memory, one register and supported 7 instructions:

000JMPs, CJump
100JRPc+s, CRelative Jump
010LDN-s, ALoad and Negate
110STOa, SStore
001SUBa-s, ASubtract
011CMPTestSkip if Negative
111STOPStopHalt Machine

With only 7 instructions the SSEM makes an ideal system for an emulation project. A basic simulator can be written in under 40 Intel x86 instructions. If you're tempted to write your own, the SSEM Reference Manual will come in handy. :-)

Saturday, 9 January 2010

8 Bit Home Computer Benchmarks

Over the years I've collected quite a few 8 bit home computers. Out of curiosity I decided to write a simple prime sieve benchmark to compare their implementations of BASIC.

10 LET W=500:DIM F(W):LET P=1:LET A=3
20 LET F(P)=A:LET P=P+1:IF P>W THEN STOP
30 LET A=A+2:LET X=1
40 LET S=A/F(X):IF S=INT(S) THEN 30
50 LET X=X+1:IF X<P AND F(X)*F(X)<=A THEN 40
60 GOTO 20

Here are the results from a few of the machines I have to hand:

System
CPU
Time
Acorn Electron
2.0MHz 6502
138
Amstrad CPC464
4.0MHz Z80A
140
Commodore C64
1.0MHz 6510
254
Commodore Plus/4
1.0 MHz 8501
267
Tandy 64K CoCo 2
0.895MHz 6809E
271
Atari 800XL
1.8MHz 6502
316
Sinclair Spectrum +3
3.55MHz Z80A
388

Let me know how long it takes to run on your favourite classic computer. :-)

Sunday, 8 November 2009

Secret Opcodes of the 8 Bit Processors

secret opcodes
Undocumented instructions were common on early processors. A few would crash the computer (HCF - halt and catch fire) while others had strange but occasionally useful behaviour. Any self-respecting programmer would make use of these to squeeze out the last few cycles of performance.

The effect of undocumented opcodes would vary between different versions of some processors, no doubt leading to the classic excuse “it worked on my machine”. Here are a few examples I've found useful.

Secrets of the Z80


Zilog's Z80 was used in a number of popular 8 bit computers including the Sinclair Spectrum, Amstrad CPC, TRS-80 and MSX. There are a number of undocumented opcodes with the CB, DD, ED and FD prefix.
  • CB30-CB37 - SLL reg shifts a register left, setting bit 0.
  • DD - when used as a prefix to instructions which use H or L, either the high or low 8 bits of IX are used.
  • FD - as DD, but the high or low 8 bits of IY will be used.
  • ED70 - IN (C) reads from i/o port C, setting the flags and discarding the result.
  • ED71 - OUT (C),0 outputs a zero to port C.

Secrets of the 8086/8088


Intel's 8088 was used in the original IBM PC and has spawned an entire family of processors.
  • D6 - SALC sets the AL register to either 00 or FF depending on the carry flag. SALC was finally documented with the introduction of the Pentium Pro 27 years later.
  • 0F - POP CS pops the CS register from the stack. Only works on 8086 processors.
  • 0F05 - LOADALL loads all registers from memory location 0800. Only works on 80286 processors.
Which processors have you programmed and did you find any undocumented opcodes useful?