0% found this document useful (0 votes)
357 views5 pages

Charm Review in Archive Magazine Jan-Feb 2012

The document provides a review of the Charm programming language, which originated in the 1980s and was recently recompiled for ARM processors. The review summarizes Charm's origins and development, provides an overview of its features and syntax, and describes the process for creating and compiling Charm programs. While the language has an old-fashioned feel, the reviewer finds its self-contained nature and ability to mix Charm and assembly code interesting, with potential for educational use.

Uploaded by

peter_nowosad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
357 views5 pages

Charm Review in Archive Magazine Jan-Feb 2012

The document provides a review of the Charm programming language, which originated in the 1980s and was recently recompiled for ARM processors. The review summarizes Charm's origins and development, provides an overview of its features and syntax, and describes the process for creating and compiling Charm programs. While the language has an old-fashioned feel, the reviewer finds its self-contained nature and ability to mix Charm and assembly code interesting, with potential for educational use.

Uploaded by

peter_nowosad
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Saturday 28th April

Acorn & RISC

as Computer

Show

2012
arsc os show
Big Names and Small Developers Show Theatre On-site catering Charity Stall
raising funds for Wakefield Hospice

Vol.23

N 4

The North's premier

Now in its 17th year


The subscription magazine for users of the Acorn Archimedes and its successors The Cedar Court Hotel Denby Dale Road, Calder Grove, Wakefield West Yorkshire WF4 3QZ
(Adjacent to J39 of the M1)

Newsbits

Jim Nagel

The Southwest show; Colossus gal/ery at Bletchley


New Arms A Movember Free to share: The Charm From for Rlscos tale close PD column a review Trevor Johnson to home Jim Nagel Steve Fryatt Gavin Wraith 6 7

Getting there by car


Easy access from M 1, M62 and major routes Free on-site parking Date Opening time Ticket price Saturday, 28th April 2012 1 0.30am to 4.30pm 5 on the door Entry for children aged 12 or under (accompanied by an adult) is FREE Disabled access to the show venue is via a lift

8 13 20 26

language:

Getting there by train


Free minibus serving Wakefield Westgate station, with connections across the UK Access
North (leed,)

particular

to general

... Gerald Fitton

Computer science
Mac Matters Mark Stephens

Enquiries Wakefield Show 2012, do 3 Riverdale Avenue, Stanley, Wakefield, WF3 4LF [email protected]

li/lOring data on three systems


:')ncret life of algorithms (6) Nicholas Cutler ... 32 lire' travelling salesman is yet on the road

Email

Show organised

..,

~ ~
'{;
South-(Sheffietd)

~.00
by

n... Mad
lipping WdlltMII ')llIplling
1111111111

Scientist

invents

Roger Darlington

... 38

\c,cosc

lilt "11ft camera redesign


audio from downloads with GCC Kindle CDs (Sound 31) Jim Lesurf Chris Newman 40 43 46

;0

" ~

-1/
~'I.!I'Il'll\JIIf1:I

(19)

Rob Johnson John Williams Julian Fry Keith Hopper

For further information,

visit

Wakefield 2012 is sponsored by

and Rlscos

51
54

'-'111 i'I'Owt)r:

Running totals (5) /915 20 II

www.wakefieldshow.org.uk
Intemet For Everyone
E&OE 0 WROCC & Stephen Pryatt. 2011

111"'''(11"10.;.IItHl

58

ill, 110/'/11'1,

It

IdvQ lill)~ III download hiV!l


IW;lIlloc)1
&'

2 .,., .... " .. " .... " . , .. I)

www.archivemag.co.uk "d~ Abbey Press Glastonbury 32 Norbins Road BA69JG (01458) 83 3603 [email protected]

Free to share: PD column converts measurements such as length, weight, volume and around 15 others between various metric and imperial units. Version 2.32 makes it easier to add new units or even entire groups. Copies can be downloaded from chris-johnson.org.uk/ softwarelunitconv. htm/ Chris Martin continues to support Jonathan Marten's vector-graphics tools, with ongoing updates to Draw Plus, Vector and Grid Pro. Draw Plus is, as its name suggests, an enhanced version of Draw; Vector took the improvements to a commercial level - albeit in a very different area to that inhabited by Artworks. Grid Pro can be used to generate many different kinds of grid in drawfile format. All three titles are now open-source. Respective versions 3.37 include various improvements and bug-fixes. Details at users.on.netl-belleslsoftwarelopenvector Gerald Fitton - who needs no introduction to Archive readers - recently announced that both Pipedream and Fireworkz are now freeware. (Fireworkz Pro, however, remains commercial, from R-Comp.) These two mixtures of spreadsheet and wordprocessor (and database in the R-Comp product) are very much Marmite applications - users either love them or hate them - but it seems unlikely that I need waste column-inches outlining their features. Details and downloads are at abacus/ine.co.uk Steve Fryatt [email protected]

[ The Charm language: a review


Gavin Wraith
Its content, however, 1 found informative For many years the Charm programming and interesting. Have a look at language, first available for RIse os users on the screenshots on the Demo page of the the Archimedes, languished in that limbo site to get a quick idea of what you can do reserved for software whose authors have with Charm. There is a forum page, and left the RIse os scene. But Peter Nowosad, you can join the Charm users' group on the creator of Charm, has returned; Facebook. On the Language page is the Charm has been recompiled for the more complete syntax of Charm and a brief modern Arm outline of the language's Abciullhls program processors. For an features. You can download ~me Chatm Iyonix user, like myself, the Charm distribution from Purpo.: ARM HLL Corr1piler it is reborn. It has " the Install page; this includes Vfl($iOll V2.4.9 (32 bit) always been available 40,000 lines of the source . Oemmbef2011 011. for PC users using code to Charm itself, written 'Allthor' e Peler Noworod RPCEmu, of course. in Charm and a small amount
<. 'I'

Someone had the bright idea of trying ~.;.,,_ to do five plays in eight months, so . Steve is fairly busy in the theatre just now - backstage for productions in Leeds. The next one is Art, taking a look at people who collect the stuff.

Archive members' ads


RiscPC seeking new home
Peter Wicks writes: "I have a StrongArm machine with a 2G hard drive, a USB interface and lots of Scsi devices attached: CD reader, CD writer and Syquest drive with 11 discs. It tells me it is Risc os 4.02 with 50M of internal memory. Software: Techwriter 8.92, Drawworks 4.58 and all the normal bits that a RiscPC comes with. It comes with an original Acorn monitor. Obviously I would expect the person who takes it to collect. I am very sad to say it has to go to make room for other things." He lives in Farnham, Surrey - (01252) 72 8035 or [email protected]

of Arm assembler. It is not that 1 ever did LIen . GNU anything with it when 1 From the Overview section GenaraJ Public UaJ".. had an Archimedes you may discover how Charm ~ see GPlV3 In $.chatm 400, beyond playing the started out in the early 1980s delightful Decapedes game demonstration, from Peter Nowosad's ambition to create but then in those days there were lots of for himself a pre-emptively multitasking other programming languages available for operating system, including a language and Rrsc os. its compiler, that could replace CP/M on These days Charm stands out a bit more, so, when its revival was announced, your editor asked me to have a look at it and this report is the result. Website woes 1 found initially that Charm's website (charm.qu-bit.co.uk) crashed Netsurf (I was using release 13208, in November 2011). The less said about the quality of the website's frameusing HTML automatically generated by yo/a.com the better. 1 could view it on a PC using Firefox without trouble, but downloading the site for offline viewing and cutting it down for Netsurfwas not straightforward. his hobbyist Pet S-100 motherboard. You had better google these terms if you are not old enough to find them familiar.

WQb'

hltp:.(/chElrm.qublt.oo.

uk

I"

Games for the cost of postage


Harriet Bazley has a batch of games looking for new homes. Most are complete with box and manual, The Crystal Maze (for Archimedes, A3010, A3020, A4000, A5000). Haunted House by Gordon Key about 1993 (for all Acorn 32-bit computers). Saloon Cars by Andy Swain (for A3000, 310, and 400 series). Wbnderland, an adventure game from Magnetic Scrolls (for Archimedes; works on a StrongArm RiscPC with Rise os 6 after a couple of tweaks). Cyber Chess by William Tunstall-Pedoe (for A3000 and all Archimedes machines); comes with chess tutorial. The Missing Dinosaur Bone adventure program by Angelsoft Educational. And some non-games: Acorn Advance (no box or manual), and these Longman Logotron titles: Advance spreadsheet, Revelation Image Pro graphics program, Pendoum Plus wordprocessor. Also the full technical documentation for the Acorn 16-bit audio card. baz/ey@feathermai/.co.uk

Decapedes _ a game demo programmed in Charm

12 Archive 23:4 January-February 2012

Archive 23:4 January-February 2012

13

The Charm language: a review Origins and re-emergence Charm was originally created by bootstrapping a core wrinen in 68000 assembly language. The port to Arm processors was effected by rewriting the compiler back-end to emit Arm rather than 68000 instructions, using a serial link between S-1 00 and Archimedes, and then recompiling on the Archimedes. Whereas most software for RIse os uses a runtime system (such as C or Basic) that has already been provided, Charm is entirely self-reliant - an impressive example of a do-it-yourself project that would be way beyond most amateur programmers. It is this aspect of Charm that I find most interesting and full of future potential. were used in schools, in the 1980s and 90s, some teachers introduced Charm to their pupils, who liked the demos and wanted to write their own. Let us hope that this happens again, when the Raspberry Pi becomes available. Using Charm Charm's origins explain its old-fashioned feel, if you have memories of computing that stretch back to the 80s. Much of its documentation was evidently written a long time ago: installation from floppy discs! "What are they?" younger readers may ask. To make a Basic program you can write it in StrongEd or Zap, save it with filetype Basic, and doublec1ick on the saved me's easy to mix Charm and assembler. By default the compiler creates the intermediate assembly and object code, and links it, in memory. The conversion of source to executable is very fast: doing the 40,000 lines of the Charm system itself takes less than 15 seconds under RPCEmu on a fast PC. Creating a Charm program - let's call it fred - requires a directory of that name with a set of eight subdirectories which must be called arm, def, inc, Ink,1st,map, obj, src and an obeyfile called -tred. The actual source code is placed in a file fred.src.fred. All this is created automatically with an application provided, called !newproject. The schematic picture shows the eight subdirectories and how they may be used by the three components (arma, armc, arml) of the Charm system. The src and def subdirectories are used by the compiler, armc, which can produce assemblylanguage output if desired in subdirectory arm.This, and any assembly language libraries in the inc subdirectory, is used by the assembler, arma, to produce object files in subdirectory obj, and, if required, listings in subdirectory 1st. The Charm object-file format is not linkable with AOF (Acorn Object File format) files. The linker, arrnl, resolves the references and combines the object-code files with the Charm runtime code to produce an executable file in subdirectory Ink. The executable can be chosen to be either an application or a relocatable module; all the messy details are dealt with automatically. This must be the easiest way so far to make programs that run from the relocatable-rnodule area.

The Charm language: a review The parts of Charm written in assembler are used for: Language startup - entering modules or applications at the with stack, heap and data section allocated correctly at the _rtl_program_start label. Calling SWIs to access RIse os. This is generally very easy because of the APCS convention that the first four parameters are passed in rO-r3 and the result is returned in rf). Writing time-critical routines - for instance, in Decapedes for custom . sprite-plotting or in the compiler for fast hash-table lookups, as deemed necessary (originally by the profiler). In short I reiterate: the newcomer does not need to know all these details. It is enough to write the source code, say fred.src.fred,and then drag the whole fred directory onto the !Charm iconbar icon. This will create the executable file with the name specified in fred.-fred. Indeed, a whole directory of different Charm projects can be compiled simultaneously by dragging onto the !Charm iconbar icon. The function of the !Charm application is to relieve the user of the need to use the commandline - though, of course, the three components, Compiler, Assembler and Linker, offer all kinds of commandline options. In this respect Charm struck me as easier to use than Acorn C or C++. Exercise for a novice I should stress that I am very much a novice with Charm. As an exercise in acquainting myself with it Peter Nowosad suggested the project of writing something performing the job of the !newproject application. I hasten to add that though

Peter Nowosad wrote a (nonwimp) text-editor to go with it. With -. version 2.4.9 he )0 [arm )--. obj ]--has updated Charm so that ~ error-throwback r=z::I Imap']~ can be used within the desktop, using the DDEUtils 11!lk module, so that icon (or press the Run button in StrongEd or Zap are now sensible StrongEd). Making a Charm program is a alternatives for creating Charm programs. bit more complicated because it is a When Charm was first devised, desktop compiled language, but the extra GUIs had not taken over from the complication is hidden from you unless command-line as thoroughly as they have you use the cornmandline. now.

t.----~
I

.~I.def]

I~
--.1

~-- t

1.___J

Charm's re-emergence is timely, thanks to the Raspberry Pi project's reminder that the do-it-yourself virtues of the early days of computing really are universal. To dismiss them as out-of-date is blindness. It may be worth saying that when Acorns

The Charm system consists of three basic components: compiler (armc), assembler (arma) and linker (arml). However, the newcomer can forget about the assembler and linker, which are provided as standalone tools for more advanced purposes. As with BBC Basic, it is very

14 Archive 23:4

January-February

2012

Archive 23:4

January-February

2012

15

The Charm language: a review

The Charm language: a review Charm module sieve; I runtime library I include "rtl" include "ri scos", canst N = 1000; const MAX = 999; I maximum prime proc out_primes (ref array boolean vector); int i, count; count := 0; for i := 2 step inc (i) while i < MAX do if not vector[i] then rtl.out.num_fld (i, 3); inc (count); if count mod 18 = 0 then rtl.out.nl (); elf1e ~ rt L out. ch (' '); end_ifi end_if; end_for; end_proc; ent proc start (int argc; ref array ref array char argv); array [MAX] boolean sieve; int i, j, tl, t2, count; tl := riscos.read_time(); for count := I step inc(count) while count <= N do for i := 0 step inc (i) while i < ~1AX do sieve[i] := false; end_fori for i := 2 step inc (i) while i < ~1AX do for j := i t i step j := j + i while j ~ MAX do s i.eve j ] r= true; I end_for; end_for; end_for; t2 := riscos.read_time(); out.. ..Primes (sieve); rtl.out.nl() .nl().num(t2-tl) .str (" centiseconds"). nl () .str ("Charm"); end_proc; end_module; -- Risclua local N,MAX = iOOO,999 local write in io __ local out = \(v) local count = I , for i = 2,MAX do ', if not vIi] then write(("%3d%s") :format(i, (count%18==0)and"\n'or" .)) count = count + 1 end -- if end -- for end -- function local clear = \(x) for i = 2,MAX do xli] = nil end end local shake = \(x) local m = MAX for i = 2,m do for j = (i+i),m,i do x[jl = true end -- for end -- for end -- function local sieve = local tl = os.clock() for count = I,N do clear(sieve);shake(sieve) end -- for local t2 = os.alock() out(sieve) local s = "\n\n%d \z centiseconds\nRiscLua" write(s:format(t2-tl)) The sieve of Eratosthenes in four languages
Gavin Wraiths code to find thejirst 100 prime numbers. (Five languages if you also count Ancient Greek.) The heading of each column illustrates how the four programming languages each have their own way of signalling a comment.

1*

*1

#include <time.h> #include <stdio.h> #define N 1000 #define MAX 999 static char sieve[MAX]; static void out (char *); void out(char *v) lint i,count; count" 1; for (i " 2; i < MAX;
i++) if (v[i] == 0)

i'5' .'

.-----.
'

c-

printf ("%3d%s h , i, (doUht+~)%18?" ":"\n"); return; int main(int argc, char **argv) { int i,j,tl,t2,count; tl = (int)clock(); for (count = 1; count <= N; count++) {for (i = 0; i < ~1AX; i++) sieve[i] = 0; for (i " 2; i < MAXi
iH)

liIdI

REM Basic N% = 1000 : MAX% = 999 @% = &03 DIM sieve%(MAX%) Tl% = TIME FOR C% = 1 TO N% PROCclear : PROCshake NEXT C% T2% = TIME PROCout PRINT (T2%-Tl%);" centiseconds""'Basic" END: REM -- end of main section DEF PROCciear LOCAL U , FOR I% = 0 TO MAX% , , s~eve%(I%) = 0 NEXT 1% E~DPROC DEF f'ROCshake LOCAL I%,J% FOR 1% = 2 TO MAX% J% = 1%+1% WHILE J% <= MAX% sieve%(J%) = 1 J% += 1% ENDWHILE NEXT U ENDPROC DEF PROCout LOCAL C%,I%
C\ = I

III.

for (j

iti; < MAX; t= i) sieve[j]


=

= 1;

t2 = (int)clock(); out (sieve) ; printf( '\n\n%d cent i seconds'vnc",


t2-tl) ;

return 0;

FOR U=2 TO MAX% IF sieve%(I%)=O THEN PRINT H; IF C%MODIB THEN PRINT" "; ELSE PRINT ENDIF C% += 1 ENDIF NEXT 1% PRINT ENDPROC

16

Archive 23:4 January-February 2012

Archive 23:4 January-February 2012

17

The Charm language: a review


my effort succeeded in doing what was asked, it cheated a bit by including assembler in the parts where my knowledge of Charm was shaky. Those parts have been recoded in Charm for !newproject. Charm comes with a useful set of libraries, which enable the writing of wimp programs using the toolbox. I have always been a duffer with the toolbox, but I found it relatively easy to use the demonstration program !Tboxdemo a basis for as !newproject. nybody with some A acquaintance with C, Pascal or Basic should find easy to get started with Charm. The language itself is reminiscent of Modula 2. It does not have memory management built in, so that, as with C and Basic, string-handling can sometimes be a pain. As with both those languages, strings are represented in memory as arrays of consecutive bytes. In consequence the programmer may be in the position of having to allocate a buffer before knowing exactly how long the string to go in it will turn out to be. The string library provides a record type _string which internally manages string-buffer allocation. Peter Nowosad plans to extend Charm with object-oriented features along the lines of C++, which may make stringhandling easier. in Charm and Arm assembler, are there for anybody to read and tinker with. You can get a flavour of how these four languages compare with each other syntactically from the four source texts on the previous two pages. Note that the output routine has not been included in the timing, Incidentally, using a byte array in the Basic program, with DIM sieve% maxprime% and sieve%?i% in place of a word array, with DIM sieve%(maxprime%) and sieve%(i%) yields slower times, even though it uses less storage. But this is to be expected on machines with an Arm CPu.

The Charm language: a review


that it is a magnificently quixotic project. It probably needs more libraries and documentation and tutorials for it to be taken up more widely. This raises the usual question: are the programmers there? would it be worth the extra effort? The Charm system is a powerful tool and it continues to be developed. Programming is rather a minority interest, despite its educational importance. I hope that enough enthusiasts will have the courage to try their hand with Charm, because it will repay the effort. Gavin Wraith [email protected]/us.com Ourfirstlessonat prep schoolwas Latin,and that blewmymind,Thatone might,even approximately, speak wordsthat couldhave been spoken two thousandyears ago was marvellous to me, Itset me to inventing secret languagesand historiesof myownformostof mychildhood,

Where to get Charm


,

"If.

Download Charm from chqrm.qu'bif.co.uk- it'~'free, distributed under (he Gnu Public Licence. It runs .on any RIse os .machine, even on an unexpanded one-megabyte Arehimedes with only a ' floppy drive. A simpler version .of the program that generated the colourful Mandelbror set on the front cover is available on the site's Demo tab. Wikipedia has' an article under "Charm (programming language) ", A video of Peter Nowosad demonstrating Charm in the theatre at the London RIse os show in November is among other films at Fiscos/ondoflshow.co,uk The, Charm graphic here - rather, more intriguing than the icon for Charm files - is the logo Peter uses for his Qubir software consultancy business. On the website, his ,caption reads: "Entangled coloured quark triplets confined by the strong force mediated by gluon ' exchange."You might know that certain elementary particles discovered since 1974 are called "charm quasks" - and some' of them decay into "strange quarks"! ,Asyou might guess, at Cambridge Peter studied theQretic~1 physics. '

Benchmarks
How fast is Charm?You can get a crude estimate by comparing the times of four programs, written in C, Charm, Risclua and Basic, which use the sieve of Eratosthenes to calculate the primes up to 1,000 a thousand times, Here are the results, calculated on an Iyonix with RIse os 5.16, in centiseconds: C Charm Risclua Basic 36 compiled (Norcroft 5.60) 34 compiled (version 2.4.7) 282 interpreted 1069 interpreted (5.40) (1.44)

Outlook
So what can Charm do for RIse os users? That is up to them. It cannot be denied

II TheARMini

The scores show dramatically the greater speed of compiled languages. When you consider that the Norcroft C compiler (658K for cc) is a commercial product developed over many years, and that the Charm compiler (l36K for armc + arml) is a one-man effort, the comparison puts Charm in a more than respectable light. Furthermore, the sources to Charm,

Your journey starts now! Are you ready?


www.armini.co.uk
Or phone R-Comp Interactive on 01925 755043

'-+i:=-------===---==-==-=---------l

.I 19

18 Archive 23:4 January-February 2012


.Ai!

Archive 23:4 January-February 2012

You might also like