From Newsgroup: comp.sys.acorn.programmer
On 1 Aug, Alexander Ausserstorfer wrote in message
<
5d019522bdalexander.ausserstorfer@eclipso.at>:
Many thanks for the explanation. What I want is to use the command SWI Hourglass_On instead of SWI 0x406C0 like in Listing 4.1.6 (on page 4).
https://ausserstorfer.4lima.de/Computer/4.pdf (83 kB)
I want to compile the Listing 4.1.6 with the GCC, but with
.global _start
_start:
SWI Hourglass_On
MOV PC, R14
instead of
.global _start
_start:
SWI 0x406C0
MOV PC, R14
That's all.
In which case, you're just using the ASM headers and it _probably_ doesn't matter.
I have no clue about the Shared C Library (what is this?),
If you're compiling C code, then RISC OS contains the "standard" libraries
in a module called the Shared C Library and compilers can link the your code
to that so that the memory is only used once by all of the applications
running on the machine. For the DDE this is the default; for GCC you'd pass -mlibscl as a parameter on the command line.
But this isn't quite the end, because Relocatable Modules (filetype &FFA)
link slightly differently to standard applications (filetype &FF8), so you
need the correct library.
With GCC, there's also the option _not_ to use the Shared C Library, but to include all of the C standard libraries within your executable. This is
often useful if you're porting C code from other platforms.
It seems to me that the GCC is very complicate. I don't understand this because the machine code
EF04 06C0 SWI Hourglass_On
E1A0 F00E MOV PC,R14
is very easy to create and it is also very easy to understand. There is no need to know anything about the SharedCLibrary, modules or applications as you wrote about I think.
True, but I can write that in C as
hourglass_on();
and leave the problem of linking it all up to the compiler. It isn't
something that I need to think about all that much.
But then in assembler, you come to write
FILE *f = fopen("myfile", "w");
for (int i = 1; i <= 10; i++)
fprintf(f, "Hello, this is line %d\n", i);
fclose(f);
and find that being able to leave the Shared C Library to worry about how fopen(), fprintf() and fclose() work is quite nice.
Anyway, I have to add OSLib for GCC in the script to complete it altough I have no clue about it. The problem here is to chose the right version of OSlib (for the GCC). What would you chose to go further with the
introduction learning programming?
For what you're doing, the unixlib-softfloat may work just fine.
I always said it is not a good idea to start learning programming by using any compiler because it makes everything so complicate and opaque. I had three semesters C programming on university but you will learn nothing
there. Or nothing you will understand.
We may have to agree to differ on that. :-)
--
Steve Fryatt - Leeds, England
http://www.stevefryatt.org.uk/
--- Synchronet 3.22a-Linux NewsLink 1.2