The comp.sys.acorn.programmer FAQ Warning: beta release. not suitable for those of a weak disposition. Subject to change without warning. Expires 980128 current maintainer: Matthew Wilcox email: willy@odie.barnet.ac.uk 0. Contents 1. Notes 2. Purpose of the group 3. What programming languages and support for them are available? 4. What are the entry/exit conditions for this SWI? 5. Some nasty BASIC gotchas. 5a. Some nasty C++ gotchas 5b. Some nasty assembler gotchas 6. What a strange error message. What does it mean? 7. I just don't understand how to do . Got any examples? 8. Some collections of software you may wish to look at first. 9. I have a comment/suggestion/complaint 10. Credits 1. Notes This FAQ is not designed to be a repository of information. Rather, it is designed to tell people where to go looking for things. 2. Purpose of the group comp.sys.acorn.programmer is a newsgroup for discussions about programming Acorn computer systems. It is not for learning how to program in general and it is not for discussing programming techniques that are not specific to the Acorn platform. You're much more likely to get a informative reply if you post to a group that's frequented by the experts in that subject. You may wish to try: * comp.lang.c * comp.sys.arm * comp.graphics.algorithms * sci.math * comp.dcom.telecom * comp.sys.acorn.networking for example. Do think broader than just the fact that it's an Acorn computer that you're typing on; the issues may well be deeper. Also, try to refrain from immediately posting when you want to know about something; is there a book that contains the answer? Have you checked some obvious sources of information on the web? You would be wise to check out the information contained in the StrongHelp manuals at http://freenet.barnet.ac.uk/manuals/manuals-index.html Robin Watts also has a large archive of documentation at http://www.comlab.ox.ac.uk/oucl/users/robin.watts/Docs/ By posting you are expect an intelligent answer - in return people who may be able to supply this answer expect intelligent questions. "Usenet does not exist to do your homework for you" - questions that are easily answered by language tutorials do not give a good impression. 3. What programming languages are available? It's perfectly acceptable to discuss various things about programming - unless they're obviously better discussed on the appropriate group for the particular language. In particular the language itself and standard library functions not specific to Acorn OSes should be discussed on the appropriate language group. (Unless, of course, it's a problem about the Acorn implementation) 3.1. Ada Peter Burwood's GNAT port is available from ftp://micros.hensa.ac.uk/micros/arch/riscos/e/e095 The older Ada/Ed port by Peter Burwood is still available from ftp://micros.hensa.ac.uk/micros/arch/riscos/c/c052 3.2. Assembler The BASIC Assembler is supplied in ROM. Acorn sell ObjAsm as part of Cv5, previously it was available separately. AOFLib, by William Gibbons, allows the BASIC assembler to save AOF files. It is available from ftp://micros.hensa.ac.uk/micros/arch/riscos/e/e108/ AS by Niklas Rojemo is available from ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a132/ ASM by Nick Roberts is available from ftp://micros.hensa.ac.uk/micros/arch/riscos/f/f029/ ExtBASICasm by Darren Salt, extends the capabilities of the BASIC assembler. It is available from http://www.banoffee.demon.co.uk/arcsalt/risc.html BAX by Ben Dooks is available from http://www.doggysoft.co.uk/ TLA by Frank Lancaster is available from ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a119/ XXX other assemblers? 3.3. BASIC Interpreter supplied in ROM. Compilers available include ABC & RiscBASIC 3.4. C Acorn sell Norcroft C v5 GCC 2.7.2 is available from ftp://micros.hensa.ac.uk/micros/arch/riscos/b/b013 *but* you will also need the patch archive from http://guest.btinternet.com/~nick.burrett/patch1.zip Easy C is sold by Beebug Documentation on C, the ANSI library, and several RISC OS libraries is in http://freenet.barnet.ac.uk/manuals/g.boden/c.zip C libraries: RISC_OSLib (Acorn) DeskLib (Julian Smith et al) Desk (Julian Smith) OSLib (Jonathan Coxhead) Toolbox (Acorn) Unixlib ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a042 3.5. C++ Acorn sell a port of AT&T's CFront as part of C v5 GCC and Easy C++ - see the section on C. C++ specific libraries: Vista (Dave Allison) Dreamscape (Mark Seaborne) ftp://micros.hensa.ac.uk/micros/arch/riscos/e/e112 3.6. Forth TileForth ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a111 AForth ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a293 ForthMacs ftp://micros.hensa.ac.uk/micros/arch/riscos/c/c073 ftp://ftp.uni-stuttgart.de/pub/systems/acorn/riscos/lang/forth/forthmacs WimpForth ftp://micros.hensa.ac.uk/micros/arch/riscos/e/e096 3.7. Fortran f2c ftp://micros.hensa.ac.uk/micros/arch/riscos/b/b136 g77 Fortran specific libraries: Fortran Friends disc 1 ftp://micros.hensa.ac.uk/micros/arch/riscos/d/d061 PGPlot ftp://micros.hensa.ac.uk/micros/arch/riscos/d/d062 3.8. Gofer gofer ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a262 3.9. HUGS hugs ftp://micros.hensa.ac.uk/micros/arch/riscos/d/d041 3.10. Icon icon ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a106 icon9 ftp://micros.hensa.ac.uk/micros/arch/riscos/e/e116 3.11. Java See Peter Naulls' Java FAQ. http://chocky.home.ml.org/ 3.12. Lisp XLisp ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a103 XLisp-Plus ftp://micros.hensa.ac.uk/micros/arch/riscos/b/b076 FoolsLisp ftp://micros.hensa.ac.uk/micros/arch/riscos/c/c162 CLisp ftp://micros.hensa.ac.uk/micros/arch/riscos/c/c189 3.13. Pascal Norcroft Pascal ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a122 Cambridge Pascal is commercial, but I don't know who sells it. 3.14. Perl Perl ftp://micros.hensa.ac.uk/micros/arch/riscos/a/a049 There is a beta release of perl 5.004_04 at ftp://ftp.unfortu.net/pub/flirble/users/nick/P/ (which is stable, but the names of some RISC OS specific functions will change shortly when perl 5.004_05 is released) 3.15. Python Python ftp://micros.hensa.ac.uk/micros/arch/riscos/e/e129 3.15a. Sather Sather 1.1 Compiler http://chocky.home.ml.org/sather/ 3.16. Smalltalk Squeak http://sumeru.stanford.edu/tim/ 4. What are the entry/exit conditions for this SWI? There are freely available manuals including Guttorm Vik's StrongHelp (other editors are also available ;-) http://login.eunet.no/~guttorvi/strong.html Justin Fletcher also has one available in HTML from http://users.essex.ac.uk/users/gerph/acorn/prog.html 5. Some nasty BASIC gotchas. Q: Why does BASIC print a silly number of decimal places when I use STR$? A: Check the setting of the @% variable. You probably need to put a + at the front. Q: Why is this multiline IF statement not working? A: Ensure there's no blank space after the THEN. The THEN must be the very last thing on the line or it will not be treated as a multiline IF. To fix this, try: !Edit: with `wildcarded expressions' turned on, Find:THEN^ $ Replace with:THEN$ !Zap: with Raw and '\' commands enabled, search for:THEN \*\n Replace with:THEN\n Also, in Zap, you can turn on the `Strip Spaces' option. Q: Why am I getting an error reported for the last line of my program? A: The BASIC interpreter often mistakenly reports the last line when another, more unusual error has occurred. For this reason many BASIC programmers like to put `REM this line cannot generate an error' as the last line of their program. Q: How can I reset my machine? A: Try this piece of assembler: SWI "XOS_Reset" SWI "XOS_EnterOS" MOV r0, #&3800000 LDR r0, [r0] STR r0, [r0, -r0] MOV pc, #0 Q: How can I reset someone else's machine over the network? A: Go away, schoolchild. Your teachers have enough hassles already. 5a. Some nasty C++ gotchas When using cin to read input from the user: > int main() > { > int a; > cout << "enter a "; > cin >> a; > return(0); > } you may find you need to add cin.sync_with_stdio() before the I/O is performed. > The code seems to compile correctly, but when run the "enter a " gets output > to the screen but then it just continually inputs, as if its missing a read > return key. 5b. Some nasty assembler gotchas This from Richard Walker: > If you want to predefine a flag for objasm, don't even think about doing it > in the way that !Objasm does it. For example, I need a logical flag set > {TRUE}. I ask !Objasm to define it, and it produces a command line > ... -predefine REAL_FP -predefine SETL -predefine TRUE ... > which, oddly enough, doesn't work. > The example in the manual is also as wrong... > The code that actually worked (in a makefile) was: > -predefine "REAL_FP SETL {TRUE}" 6. What does this strange error message mean? Error: No writable memory at this address Cause: This error is produced by FileSwitch when it finds there's no memory at the address that it was asked to load a file at. The most common cause of this is wimpslot too small. Fix: Make the wimpslot larger. Alternatively, are you maybe running something else in your !Run file which adjusts the wimpslot before your application starts? Error: AMU crashes unexpectedly Cause: The self decompression code (for example in the C compiler) does not check the memory limit, which results in parts of AMU in memory being overwritten. When control returns to AMU, it crashes Fix: Make the wimpslot larger Error: EMT trap Cause: The program is linked with UnixLib, which unlike the standard C library cannot automatically extent the stack. UnixLib generates this cryptic message when it detects that it has run out of stack space Fix: Make the wimpslot larger Error: Data Lost Cause: Generally, you've got a write-protected floppy Fix: Move the write protect tab on the floppy ;-) As a rule of thumb, if you are lost for a solution, see if the problems goes away when you increase the wimpslot. 7. I just don't understand how to do . Got any examples? How to: Use taskwindows properly (Matthew Wilcox) ftp://ftp.barnet.ac.uk/pub/Acorn/taskwin.arc Write a wimp application in Logo (Matthew Wilcox) http://www.york.ac.uk/~mrw103/logotask.arc.bin Use OS_GBPB to read a directory listing (Nick Clark) ftp://ftp.barnet.ac.uk/pub/Acorn/programming/doc/osgbpb.txt 8. Some collections of software you may wish to look at first. These people or companies have put together their own collections of stuff. The stuff here is not necessarily disjoint from that in the previous section. If you see something here that should be referenced explicitly above, let me know. Acorn Computers Ltd http://www.acorn.co.uk/ ARM Ltd http://www.arm.com/Architecture/CodeExamples/ Robin Watts http://www.comlab.ox.ac.uk/oucl/users/robin.watts/Docs/ Hensa Micros ftp://micros.hensa.ac.uk/micros/arch/riscos/ Alun Da Penguin ftp://penguin.fluff.org/pub/arch/ 9. I have a comment/suggestion/complaint Fine. Mail me. I only took this on after seeing yet another thread on random number generation. If you think you can do better, go ahead. 10. Credits Contributors include: Paul Boddie Nick Clark Kieran Mansley Peter Naulls Richard Walker Matthew Wilcox Mark Wooding