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?

Sunday, 20 September 2009

A History of Programming Games 1961-1989

In a programming game players write a program to complete a specific task, usually to wipe out all opponents. The contest takes place between either programs in the memory of a virtual computer or robots in an arena.

Darwin


In August 1961, Douglas McIlroy, Robert Morris and Victor Vyssotsky invented Darwin and the programming game genre. Programs written using IBM 7090 machine code competed to destroy all opponents and be the most prolific replicator. An Umpire provided three functions to probe memory for an opponent, to claim memory or kill an opponent.

RobotWar


RobotWar was written in the 1970s by Silas Warner for the PLATO computer system and published commercially for the Apple II by MUSE Software in 1981. Programs written in a proprietary high level language control robots which battle to eliminate all opponents in a virtual arena. In the early 1980s a society was formed and an annual tournament organised by Computer Gaming World.

Color Robot Battle


The Image Producers released Color Robot Battle in 1981 for the TRS-80 Color Computer. The game was played by writing programs in a simple hybrid of BASIC and Logo to control a battle robot. Programs faced each other in a one-on-one battle with the last robot standing being declared winner.

Core War


Alexander Dewdney described Core War in the May 1984 issue of Scientific American, introducing programming games to a wide audience for the first time. Core War became popular overnight. A society was formed, a newsletter published and regular tournaments held. Core War is played between assembly languages programs in the memory of a virtual computer. Each program attempts to eradicate all opponents. Core War can be played by email at KOTH.org or KOTH@SAL.

DROID


Inspired by RobotWar, DROID was developed at Reichhold Chemicals as a teaching aid in December 1984. Programs to control robots are written in the D-code assembly language and attempt to exterminate all adversaries in the virtual arena. DROID can be played by Telnet on the Empire HPe3000 server.

CROBOTS


Tom Poindexter published CROBOTS as shareware in December 1985 after being inspired by RobotWar. A subset of C is used to control battle robots. As usual, the aim of the game is to destroy all opponents in a virtual arena. A king of the hill tournament is organised by Maurizio Camangi.

P-Robots


In 1988 David Malmberg released P-Robots, a robot battle game based on a subset of the Pascal programming language and inspired by CROBOTS. Later versions introduced a variety of optional extras for robots, teams and obstacles.

OMEGA


OMEGA is a programming game written by Stuart Marks and published by Origin Systems in 1989. The object of the game is to program a tank to defeat a series of increasingly more powerful enemies. Each opponent defeated unlocks a higher security clearance and increased budget.

Unfortunately there's very little information about some of these games online. Do you remember playing any of the above? Which is your favourite programming game and why?

Thursday, 10 September 2009

#songsincode - Lyrics for Programmers

#songsincode#songsincode are small pseudo-programs which display a song title or part of the lyrics. The more refined examples use conditional code and control stuctures to define the song.

The tag was first used on twitter a couple of weeks ago. After a sudden burst of popularity, #songsincode has slowed to about 20 tweets a day. Here's an example by testydonkey:

if(Door.Color == System.Color.Red)
{ Door.Color = System.Color.Black; }

This is Paint it Black by the Rolling Stones, “I see a red door and I want it painted black”.

Here's the top 25 countdown of the very finest #songsincode. Can you identify all 25? Is your favourite missing? Let me know :-)

anurse:
var s = new Submarine(Color.Yellow);
s.Residents.Add(Us); for(int i=0;i<2;i++)
{Assert.IsTrue(s.Color == Color.Yellow);}

darrennisbett:
h=new hotel(); h.name="california";
h.guest.addEvent("checkout");
h.guest.removeEvent("leave")

royvanrijn:
if(grass=="green" && girls == "pretty")
{ takeMe(paradiseCity); }

injenierobarsa:
for (int i = 1; i <= 99; i++)
{ redBalloons[i].goBy() }

3d0:
if(my.sexyness>shirt.sexyness) pain();

phikachu:
me.color = 0x0000FF;
me.text = “Da Ba Dee Da Ba Di”;

Borisson:
($horse_name == false ? $location = desert : ' ');

plaxdan:
self.vehicle = new CombineHarvester();
you.setKey(vehicle.getKey());

cargoweasel:
SubwayWalls.write(words_of_the_prophets());

Leadhyena:
I.send("...---...",world);
I.send("...---...",world);
while(!(someone.receive(bottle)&&
bottle.contains(message)){I.hope()}

antallan:
substring("the tiger",6,1)

pitsk:
void shootPeople() { shootSherif; return;
shootDeputy; }

sbruchmann:
if ($angelsDeserveToDie) { iCry(); }

royvanrijn:
while( !me.like(mondays) ) { tellWhy(me); }

Levistica:
cuts.firstElement().deepness = max;

uberTof:
final--;

plaxdan:
while (thing != that) { doForLove(thing);

numptygeek:
jumpWithDirection(left); stepWithDirection(right);

CarstenHagemann:
$jealous_sky[$sun] = $you->tell()
if ($we->walk($fields_of_gold));

numptygeek:
if(somethingStrange==true && location ==
neighborhood){ ghostbusters();
printf("I ain't afraid of no ghost");}

draconum:
//roxanne.putOnLight('#ff0000');
commented out, was not necessary

brozow:
video$ kill -9 `ps -ef | grep radio*`

rennyhernandez:
stuff={'red door','a line of cars', 'my heart'}
stuff.each do |it| it.setColor('#000000') end

codepo8:
.clowns{float:left;}.jokers{float:right};
#me_you{position:fixed;margin:0 auto;width:100%}

royvanrijn:
for(Leaf leaf:leafs)
{ leaf.setColor(new Color(139,69,19)); }
sky.setColor(Color.GRAY);

#moviesincode, #tvincode, #booksincode!


#songsincode has inspired three new tags. Can you see #moviesincode, #tvincode or #booksincode catching on? :-)

sijmen:
TypeError: Result of expression this.spoon'
[undefined] is not an object

rhizomecowboy:
trace(isNAN(prisoner));

nail7:
var i = count(MonteChristo);

#songsincode, lyrics for programmers