This resource includes primary and/or secondary research. Learn more about original research at Wikiversity. |
This article by Dan Polansky briefly looks at AMOS programming language for the Amiga line of computers (Motorola 68k-based computers strong on graphics and sound for games at their heyday), which is a structured and procedural dialect of BASIC with certain batteries included, especially those suitable for programming of simple games. The article intends to go beyond the Wikipedia article in providing a better idea about the language and supporting anyone curious enough to want to run AMOS in an Amiga emulator for Windows and play around with it.
AMOS was originally interpreted, but later, a compiler was made for it.
The source code files are stored in a binary form rather than as plain text file.
The source code editor features folding of procedures.
AMOS facilities:
Variables, data types and literals:
'Integer COUNT=30 COUNT2=$20 'Floating-point number PI#=3.141592 'String NAME$ = "Joe Hoe" 'Zero-indexed arrays Dim INT(9), FLT#(9), STRING$(9), MULTIDIM(9, 1)
Control structures:
If X ... End If Repeat ... Until X While X ... Wend
Procedures:
Procedure PROC_NAME[ARG_NAME, ARG_NAME2] ... End Proc
Plotting graphics:
'A single point Plot 10, 10 'A line Draw 245,24*5+20 To 250,24*5+20 'A rectangle outline Box 0, 0 To 10, 10 'A circle outline Circle 10, 10, 5
Music and samples:
'Load and play a tracker module Track Load FILEPATH, 1 Track Play 1 'Play a sound sample number 5 at a certain frequency Sam Play CHANNEL, 5, 7000
'Read: 8-bit, 16-bit and 32-bit Peek(ADDR) Peek$(ADDR, LENGTH) Deek(ADDR) Leek(ADDR) 'Write: 8-bit, 16-bit and 32-bit Poke ADDR, VAR Doke ADDR, VAR Loke ADDR, VAR 'Take address of a variable Varptr(VAR) 'Load machine code into a memory bank Pload FILENAME$, BANKNR 'Start of a memory bank Start(BANKNR) 'Call machine code Call(ADDR) 'Access 68k CPU registers VAR=Dreg(REGNR) Dreg(REGNR)=VAR VAR=Areg(REGNR) Areg(REGNR)=VAR 'Copy a byte sequence Copy STARTADDR,ENDADDR To DESTADDR
See Game Duenix for Amiga computers for more plentiful examples of various AMOS facilities.
Complete guides to the language from the original language publishers are in the further reading at the end.
Limitations include the following:
Based on Wikipedia:
Further reading:
Alternative BASIC implementations for the Amiga, competing with AMOS during its heyday:
Given the kind of facilities AMOS has, there seems to be no obvious reason why compiled AMOS could not be as fast as the C language. An empirical performance comparison is missing. It seems unlikely that compiled AMOS was as fast as C, but it is unclear what the case actually is and why that is. AMOS compiler itself was not written in C but in assembly[4].
One area where AMOS is expected to get slow is strings and their operations such as concatenation. I (Dan Polansky) remember writing a text format conversion tool in AMOS; I started using the built-in string facilities, but it was very slow and I could only make it perform well by switching to low-level facilities directly working with bytes and their sequences.
Compared to Blitz Basic, user Predseda tells us Blitz Basic is faster than AMOS (merely a hint since hearsay, but plausible enough).[5]