> Rob Kendrick wrote: > > On Tue, 13 Oct 2009 16:17:18 -0700 (PDT) > > Terje Slettebø <tslett...@gmail.com> wrote:
> >> Furthermore, what we've lost in simplicity, we've gained in power, > >> such as the SIMD and VFP instructions. Finally, we have ARM chips that > >> have built-in floating point computation (even SIMD and vector > >> operations), and quite frankly, I think that's worth the added > >> complexity.
> > Although for any decent performance you're forced to use > > single precision. Double precision in A8 and upwards is depreciated, > > and not pipelined. And you still have the problem that C code running > > on an x86 is faster than hand-crafted assembler on the fasted ARM. The > > VFP has been deprecated in A8 and above, like the FPA10 was in ARM11. > > Don't rely on it appearing in future processors.
> Double precision and VFP have not been deprecated, far from it. As you > mentioned in a latter reply, A8 has VFP lite which is optimised for size > (in gates). A9 has a VFP implementation optimised for speed and is a lot > faster.
> VFP is the recommended option for floating point (single and double). > Neon is a SIMD engine and should be used as such (doing multiple > operations in parallel), for one operation VFP should be used. Also Neon > is not IEEE 7xx (I never remember the exact number) compliant, VFP is.
You're right. ARM has also confirmed this (I asked them).
On Fri, 16 Oct 2009 00:29:03 +0100, Rob Kendrick wrote: > On Thu, 15 Oct 2009 19:49:35 GMT > Jake Waskett <j...@waskett.org> wrote:
>> On Thu, 15 Oct 2009 14:56:35 +0100, Rob Kendrick wrote:
>> > If you want to remain compatible, you need to use SWI for EABI, >> > however.
>> I don't understand. Are you saying that it's necessary to use >> EABI-style SWIs in order to be compatible with something? If so, with >> what, and why?
> Code from other EABI platforms. In the same way Linux and RISC iX have > RISC OS personalities. There is a standard SWI number used for EABI, > and a looser standard for different UNIX-flavoured system calls.
Yes, I looked into this about six months ago. As I recall, it's SWI 0x0 - the same as OS_WriteC. I guess it would be possible to set an internal flag when loading non-RO apps, but it could be messy. Anyway I'm not sure how much of an advantage there would be in running POSIX-type apps on RISC OS: RO is a great platform, but it isn't designed to be a POSIX platform, and is weak in that respect. It seems to me that improving the performance of RISC OS "SWI"s would be far more beneficial than emulation layers for running code written for other platforms.
Jake Waskett <j...@waskett.org> wrote: > > Code from other EABI platforms. In the same way Linux and RISC iX > > have RISC OS personalities. There is a standard SWI number used > > for EABI, and a looser standard for different UNIX-flavoured system > > calls.
> Yes, I looked into this about six months ago. As I recall, it's SWI > 0x0 - the same as OS_WriteC. I guess it would be possible to set an > internal flag when loading non-RO apps, but it could be messy.
Not as messy as the rest of the state that the WIMP stores on each process already.
> Anyway I'm not sure how much of an advantage there would be in > running POSIX-type apps on RISC OS: RO is a great platform, but it > isn't designed to be a POSIX platform, and is weak in that respect.
Well, there's plenty of value of running POSIX applications under RISC OS. Look at Firefox and NetSurf (which is POSIX) for examples.
There have been efforts in the past to allow running of ARM Linux binaries directly under RISC OS, and it worked after a fashion. (A module that provided Linux's OABI syscall interface via SWI)
> It seems to me that improving the performance of RISC OS "SWI"s would > be far more beneficial than emulation layers for running code written > for other platforms.
But it's not possible to do and get an advantage, unless you want to throw away all your existing software.
In message <gemini.krgxo3001qq0m033c.s...@softrock.co.uk> Vince M Hudd <s...@softrock.co.uk> wrote:
> Gazza <use...@garethlock.com> wrote: > > On Oct 11, 6:20 pm, Chris Johnson <chrisjohnson+n...@spamcop.net> wrote:
> > > Get the Archive DVD and all this will be at your finger tips at the > > > click of a mouse. The HTML version has full (live) indexes and cross > > > references.
> > This sounds like the best way to go then... I guess the next question is > > where to get this DVD and how much do I have to fork out?
On Fri, 16 Oct 2009 10:52:32 +0100, Rob Kendrick wrote: > On Fri, 16 Oct 2009 09:04:15 GMT > Jake Waskett <j...@waskett.org> wrote:
>> > Code from other EABI platforms. In the same way Linux and RISC iX >> > have RISC OS personalities. There is a standard SWI number used for >> > EABI, and a looser standard for different UNIX-flavoured system >> > calls.
>> Yes, I looked into this about six months ago. As I recall, it's SWI >> 0x0 - the same as OS_WriteC. I guess it would be possible to set an >> internal flag when loading non-RO apps, but it could be messy.
> Not as messy as the rest of the state that the WIMP stores on each > process already.
Fair point. :-)
>> It seems to me that improving the performance of RISC OS "SWI"s would >> be far more beneficial than emulation layers for running code written >> for other platforms.
> But it's not possible to do and get an advantage, unless you want to > throw away all your existing software.
I'm not sure if that's true. I've outlined a system that would work (I reckon), but can't be sure without testing whether it would offer a performance advantage or not. My guess is that although it would cost an extra 5 or so instructions per "SWI", the improved d-cache behaviour would lead to a small overall gain in performance.
On 14 Okt, 00:36, Rob Kendrick <n...@rjek.com> wrote:
> On Tue, 13 Oct 2009 15:12:36 -0700 (PDT) > But by ARMv9, we'll have something more CISCy than x86. No, > seriously. It's dangerously close to that complex now. We already get > to deal with the joys of remembering which instructions can be > conditionally executed, and which only work on even-numbered registers, > which operate on which halves of words, etc etc.
> ARM is no longer elegant. ARM is now a CPU designed for performance, > and not for the joy of the programmer.
A few days ago, I saw a great interview with Steve Furber, one of the people behind the development of the ARM processor (http:// www.computinghistory.org.uk/det/5438/Steve-Furber-Interview-17-08-2009/), and it's quite clear that two of the aims behind the ARM processor was performance, and low interrupt latency.
It may be argued that these things are still driving the design, in particular performance/Watt.
In other words, the "joy of the programmer" doesn't appear to have been a design aim, and in fact, RISC processors have tended to be more difficult to program in assembly than CISC processors, due to it typically requiring more instructions to perform a task, compared to the CISC version.
Fortunately, the ARM marries the easy to program part with performance, but my point is that it appears they are still following the original aims, even if it has lead to a drastically more complex processor (especially due to all the specialised SIMD, etc. instructions).
Anyway, what is elegant is subjective, and I still find ARM overall to be an elegant processor (in particular with regard to other mainstream processors), and SIMD/FP support are definitely useful additions.
Terje Slettebø <tslett...@gmail.com> wrote: > A few days ago, I saw a great interview with Steve Furber, one of the > people behind the development of the ARM processor (http:// > www.computinghistory.org.uk/det/5438/Steve-Furber-Interview-17-08-2009/), > and it's quite clear that two of the aims behind the ARM processor was > performance, and low interrupt latency.
tbh, I had always assumed the main aim was to build something that worked, and something cheap :)
> In other words, the "joy of the programmer" doesn't appear to have > been a design aim, and in fact, RISC processors have tended to be more > difficult to program in assembly than CISC processors, due to it > typically requiring more instructions to perform a task, compared to > the CISC version.
On the other hand, the instruction set was devised by a programmer who loved the way 6502 worked.
> Anyway, what is elegant is subjective, and I still find ARM overall to > be an elegant processor (in particular with regard to other mainstream > processors), and SIMD/FP support are definitely useful additions.
> > and it's quite clear that two of the aims behind the ARM processor was > > performance, and low interrupt latency.
> tbh, I had always assumed the main aim was to build something that worked, > and something cheap :)
The interrupt latency issue is one that Steve seems to mention a lot in these talks. From memory (having heard a couple of his recent Acorn-group talks), the problem was that they wanted to design the Archimedes (as it became) using the same techniques as the Beeb. The Beeb relied on interrupts to operate, and Steve and Sophie found that the CISC processors of the day were, in the worst case, simply not up to things like disc or network access.
On 17 Okt, 01:35, Rob Kendrick <n...@rjek.com> wrote:
> On Fri, 16 Oct 2009 14:06:45 -0700 (PDT)
> Terje Slettebø <tslett...@gmail.com> wrote: > > A few days ago, I saw a great interview with Steve Furber, one of the > > people behind the development of the ARM processor (http:// > >www.computinghistory.org.uk/det/5438/Steve-Furber-Interview-17-08-2009/), > > and it's quite clear that two of the aims behind the ARM processor was > > performance, and low interrupt latency.
> tbh, I had always assumed the main aim was to build something that > worked, and something cheap :)
I assume you're joking, here, because of your earlier positive comments on ARM, at least the earlier versions. :) Clearly, the simplest would be to use an off-the-shelf processor, but they didn't find any they were satisfied with, so they decided to try and make their own.
In a way, I guess you can say that simplicity was part of the original aim, because they were (intentionally) set up in such a way that they had to keep the design very simple...
> > In other words, the "joy of the programmer" doesn't appear to have > > been a design aim, and in fact, RISC processors have tended to be more > > difficult to program in assembly than CISC processors, due to it > > typically requiring more instructions to perform a task, compared to > > the CISC version.
> On the other hand, the instruction set was devised by a programmer who > loved the way 6502 worked.
Yes, and I found that a cute little processor, too (I did some assembly programming for it on the BBC Micro).
Don't get me wrong: I like simplicity, as well. Just so you know where I'm coming from, these are some of the things I in particular appreciate about the ARM (which were even more unique at the time it was released):
16 32-bit general-purpose registers Three-register architecture Conditional execution of every instruction Optional updating of the PSR Optional shift of one of the operands 32-bit instructions Simple, yet complete instruction set
The extASM assembler (mentioned in an earlier message) auguments this, by providing "auto-expansion", by increasing the range of operation of each instruction, by automatically changing it, or substituting it with several instructions, for example:
This makes it possible to write assembly code with less concern for the limitation of the instructions (although you should understand how they are transformed, when needed, so that you don't inadvertantly create inefficient code).
Now, some of the things in the above list don't quite hold, anymore, namely:
Conditional execution of every instruction Simple, yet complete instruction set
I'm no expert in microprocessor design, and maybe real-life use have a need for 30 or so different variations of the multiply instruction, as well as the plethora of other instructions in ARMv7, some of them appearing to be very specialised.
I, too, prefer general facilities, compared to specialised features and instructions (which is why I liked ARM so much when it came, and why I disliked, and still do, the x86, with its abundance of special cases and baggage from the past).
However, I also realise that for the ARM to be able to compete in its market (or any market), it may need to acquire specialised or esoteric features. I don't care much about Thumb, either (and it won't be implemented in extASM), but I understand that in some segments of their market, code desity is important (even if it reduces performance), and it is, after all, their market.
I would have preferred that ARM focused more on performance, and less on low power use, competing against processors like x86, rather than aiming for the mobile market, which could have avoided quite a bit of these things (such as Thumb). However, I also realise that they may not have had much chance against giants like Intel in this market, and it appears that going for the niche market of mobile and embedded devices have been a winning move.
Since you're clearly not happy about the way the ARM processor has evolved, let me ask you this: What would you have preferred that ARM (the company) did differently, and would it have made business sense (enabling them to survive and grow their business)?
> > Anyway, what is elegant is subjective, and I still find ARM overall to > > be an elegant processor (in particular with regard to other mainstream > > processors), and SIMD/FP support are definitely useful additions.
> You may also like PowerPC.
I don't know much about it (and finding an assembly code reference for it online has proven difficult), but from what I remember, having looked at it some in the past, I think it lacks quite a few of the things that I like about ARM, as given in the above list.
Just to be clear: I like simplicity, elegance, and generality of design just as much as you. It's just that the reality of the market you're in will shape the design, and sometimes it may be difficult to keep some of these things as a design evolves.
Case in point: As the number of instructions grew, it has apparently been difficult to keep the feature of having all instructions conditionally executable, and giving the choice between, say, unconditional SIMD instructions, and no SIMD instructions at all, I think the former makes sense as a choice.
Steve Fryatt <n...@stevefryatt.org.uk> wrote: > The interrupt latency issue is one that Steve seems to mention a lot in > these talks. From memory (having heard a couple of his recent Acorn-group > talks), the problem was that they wanted to design the Archimedes (as it > became) using the same techniques as the Beeb. The Beeb relied on > interrupts to operate, and Steve and Sophie found that the CISC processors > of the day were, in the worst case, simply not up to things like disc or > network access.
It also allowed them to cut some corners on other hardware. For example, floppy controllers since the original IBM PC were designed for DMA. They don't have big buffers, but the idea is that they DMA the floppy data straight into memory. That means a DMA controller and some extra latches to enable memory to be driven, which cost money (and potentially silicon area).
The Archimedes architecture has fast interrupts (FIQs), and so saves the cost of a DMA controller. When the floppy controller produces a byte, the processor gets a FIQ, stops what it is doing, grabs the byte, stores it in memory then gets back to work. Due to the separate overlay registers R8-R15, there's minimal overhead in switching to the FIQ routine. Econet works on the same principle.
This means you can throw away the extra hardware demands, but it doesn't scale. If the floppy controller is producing 10Kbyte/s, you can cope with 10K interrupts/sec. If it's producing 10Mbytes/s, you can't. The extra hardware really does win in the end because it decouples the CPU from the I/O.
But the idea of FIQs is a good one, especially in the embedded sphere. And it does allow you to do things you couldn't previously do, with (AFAICS) minimal knock-on effects for other things.
Jake Waskett wrote: > On Wed, 14 Oct 2009 10:53:46 +0100, Rob Kendrick wrote:
>> On Wed, 14 Oct 2009 09:04:18 GMT >> Jake Waskett <j...@waskett.org> wrote:
>>> I wonder if RISC OS could support another system call convention >>> alongside the classical SWI interface. It might be necessary to use >>> the old interface for some SWIs with register usage that made change >>> impossible, but I wouldn't be surprised if most could be supported. It >>> might even be possible to dynamically patch applications to use the new >>> interface.
>> You can most likely implement the EABI syscall system as a stand-alone >> module in RISC OS that registers a normal SWI handler.
> As I recall, EABI uses SWI 0, so I don't think it could be implemented > without clashing with OS_WriteC. And as you say, even if it could be > implemented, it wouldn't buy any benefit.
We already have a similar mechanism of OS_CallASWI, but it can't be patched in to applications as it requires and extra register to be passed to the SWI.
When I started this thread a while back looking for a beginner's guide to programming Acorn machines in BBC BASIC's built in assembler, I never knew I'd open such a can of worms. It's been fun reading it.
Gazza <use...@garethlock.com> wrote: > When I started this thread a while back looking for a beginner's guide > to programming Acorn machines in BBC BASIC's built in assembler, I > never knew I'd open such a can of worms. It's been fun reading it.
So what did you end up doing? Did we convince you that you really wanted to learn Haskell, or .NET, or Z? ;-)
On Nov 3, 4:11 pm, Theo Markettos <theom+n...@chiark.greenend.org.uk> wrote:
> Gazza <use...@garethlock.com> wrote: > > When I started this thread a while back looking for a beginner's guide > > to programming Acorn machines in BBC BASIC's built in assembler, I > > never knew I'd open such a can of worms. It's been fun reading it.
> So what did you end up doing? Did we convince you that you really wanted to > learn Haskell, or .NET, or Z? ;-)
> Theo
Well... I think I'll eventually end up doing what I started out thinking about in the sense that I'll one day get that Invaders clone you saw running at the show on the 3rd October moved from raw BASIC to, at least, partial assembler. Once I have the speed and knowledge from that, I might try and implement some sort of starfield or background overlay with the space station in the background a la the original arcade hardware. The other thing that comes to mind is maybe try and implement the bunkers a la the original with pixel level destruction rather than bumping them around like pinball targets. The other things I'd like to get right are the timings. (Running the game on a 48MHz A7000+ is about right, whereas it's too fast really on a RPC.) The accuracy of some of the collision detection code. (Trying to destroy a zig-zag type invader missile is a bit hit and miss.) But where to start??
I'd want it 32 bit friendly and I'd want it to work pretty much as it does now. I'd probably just convert the event handlers to asm and leave the rest of the stuff in BASIC. After all it's the animation and re-draw stuff that needs to be quick. This would have two advantages over doing it in C. I would be able to work on the existing code-base rather than re-coding from scratch. I wouldn't have to learn the ins and outs of how BASIC stores files written in PRINT# format.
I might do it in C first, just to see if compilation as opposed to BASIC mashing is any faster, but I've always fancied trying to learn asm. Simple generic ARM certainly seems to be more palatable to me than x86. Certainly to begin with anyhow. It also has the advantage that there's a perfectly good assembler already built into the machine... lol
On 4 Nov, 19:10, Gazza <use...@garethlock.com> wrote:
> Well... I think I'll eventually end up doing what I started out > thinking about in the sense that I'll one day get that Invaders clone > you saw running at the show on the 3rd October moved from raw BASIC > to, at least, partial assembler. > <snip> > I might do it in C first, just to see if compilation as opposed to > BASIC mashing is any faster, but I've always fancied trying to learn > asm. Simple generic ARM certainly seems to be more palatable to me > than x86. Certainly to begin with anyhow. It also has the advantage > that there's a perfectly good assembler already built into the > machine... lol
Sounds like fun. :)
I think you will find learning assembly code rewarding... I agree with you about x86 vs ARM: I would never want to write x86 assembly code... Then I'd rather go for a higher-level language. However, I've found writing ARM assembly quite fun and rewarding, and as mentioned in an earlier post, I'm currently updating the extASM ARM assembler, which is itself written in assembly (about 25,000 lines of it), to the latest ARM models (ARMv7).
extASM is a free-standing assembler, but if it turns out to be a practical possibility, now that we have RISC OS Open, it might also be used as the basis for an updated BASIC assembler...
There are a _lot_ of new instructions in ARMv7, compared to ARMv3/ ARMv4 (the ones currently in use in computers like RiscPC), including a powerful floating point instruction set (something that has been sorely lacking for years), long multiply instructions, and SIMD instructions, and these are currently unavailable in the BASIC assembler.
Also, to take advantage of them, you need to run RISC OS on hardware with the latest ARM models, such as the BeagleBoard, or Touch Book (if we get RISC OS ported to the latter).
Regards,
Terje
P.S. Feel free to contact me at tslett...@broadpark.no, if you have questions about ARM assembly, or if you'd like to discuss something.
> On Nov 3, 4:11 pm, Theo Markettos <theom+n...@chiark.greenend.org.uk> > wrote: > > Gazza <use...@garethlock.com> wrote: > > > When I started this thread a while back looking for a beginner's guide > > > to programming Acorn machines in BBC BASIC's built in assembler, I > > > never knew I'd open such a can of worms. It's been fun reading it.
> > So what did you end up doing? Did we convince you that you really wanted to > > learn Haskell, or .NET, or Z? ;-)
> > Theo > Well... I think I'll eventually end up doing what I started out > thinking about in the sense that I'll one day get that Invaders clone > you saw running at the show on the 3rd October moved from raw BASIC > to, at least, partial assembler. Once I have the speed and knowledge > from that, I might try and implement some sort of starfield or > background overlay with the space station in the background a la the > original arcade hardware.
I did that once for my program !Planets. A small machine code routine which wrote directly to screen memory. It is a hack and only works in one mode - but work it did.
In message <02083a60-2a2c-4ee1-91f7-41894e394...@c3g2000yqd.googlegrou ps.com> Gazza <use...@garethlock.com> wrote:
> I'm interested in cutting my teeth in ASM. Are there any resources out > there for beginners. I've been writing in BASIC for years and I think > I'm ready to move up a gear.
Up a gear? I'm not sure that metaphor works: In higher gears the wheels of a car rotate more times per revolution of the engine's crankshaft. Likewise, a single statement in a high-level programming language typically encapsulates more behaviour than a statement in a low-level language. You would use assembly language to get more 'traction'! :-)
Anyway, enough of strained analogies.
> I would need something fairly recent. By > recent, I mean aware of the changes required to be 26/32 neutral. I > would probably start off with using the assembler built into BASIC > rather than buying any development tools, so I'd prefer something that > was either neutral in that respect or something that concentrated on > the BASIC assembler.
I started out with ARM assembly language programming using Nick Roberts's ASM ( http://tigger.orpheusweb.co.uk/programs/misc.html ). This is similar to Acorn's ObjAsm in that it comes with a desktop front-end powered by the FrontEnd module and generates AOF files suitable for linking with compiled C source code. ASM has some nice features (named data structures, conditional assembly, macros and a few built-in functions for use in constant expressions) and the major benefit that it is free.
However, I eventually abandoned ASM in favour of Acorn's ObjAsm because ASM is far less powerful than the assembler built into BBC BASIC. I needed an assembler with all the features of the BASIC assembler but which could generate AOF output for linking with new code that I had written in C for Star Fighter 3000. As a result, the source code for Star Fighter 3000 is currently a mixture of C, ASM and ObjAsm assembly language!
The trouble was that ASM doesn't support loops and its support for conditional assembly is severely limited in that sections of code can only be included or excluded depending on whether or not a 'flag' has been defined. In contrast, ObjAsm allows arithmetic, boolean and string variables with either local or global scope, and can evaluate complex expressions as the condition for its WHILE and IF directives.
As an example of the kind of thing that would be impossible using ASM, here is a snippet of the texture mapping code for SF3000:
Richard Murray provides an appraisal of various assemblers for RISC OS machines here: http://www.heyrick.co.uk/assembler/apcsasm.html I certainly disagree with his opinion that "ASM leaves objasm standing", although no doubt someone will be along soon to say that I have unfairly impugned ASM.
> I know I could move onto C, but with the two competing environments > out there, which one? GCC or Norcroft?
If I'm quite honest, I don't think that time spent learning assembly language in this day and age is time well spent (except perhaps for the edification and amusement of enthusiasts).
I made the transition from programming BASIC to programming in C almost exactly ten years ago. At the time I was disappointed with the poor performance of early programs that I wrote in C (which no doubt used floating point arithmetic liberally). In retrospect I suppose I was still in thrall to the proud claims on the packaging of Archimedes games that they were '100% hand-optimised machine code' (as if that were a good thing!). However, I have since realised that using efficient and appropriate algorithms is far more important than the choice of language used to implement them.
If optimisation is required then an experienced C programmer can use simple tricks like using automatic variables to avoid dereferencing a pointer multiple times, whilst keeping in mind the limited number of variable registers available within each function. (It is no faster to load an automatic variable's value from the stack than it would be to access a structure member by dereferencing a pointer, and the ARM has already wasted time by copying that member's value to the stack!)
I often optimise my C programs after examining the ARM code produced by the compiler, but nowadays I would almost never abandon the abstraction and portability of C in favour of assembly language. It's nice to be able to compile the same source code for other platforms, even if the results are sub-optimal! :-)
My early attempts at writing C were stunted by the fact that I was translating directly from BASIC (sometimes mentally, sometimes using a program that I had written to do the conversion automatically). There are superficial similarities because they are both imperative languages, but C is so much more powerful than BASIC that I urge you to discard your preconceptions and buy a decent textbook on C programming. I like 'The Practice of Programming' by Kernighan and Pike.
For example, the lack of function pointers in BASIC makes it almost impossible to write reusable code that doesn't suffer from hopeless interdependencies between modules. Other features of C which initially passed me by were the ternary operator ?: (best used in moderation), the fact that the three expressions following a 'for' statement can be *anything* (whereas BASIC's FOR keyword can only be used to iterate through a linear numeric series), and the nicer alternative to GOTO provided by the 'break' and 'continue' statements.
<christopher.baz...@blueyonder.co.uk> wrote: > In message <02083a60-2a2c-4ee1-91f7-41894e394...@c3g2000yqd.googlegrou > ps.com>
Hi Chris.
Great to hear from one of the authors (or maybe the author) of Starfighter 3000, my favourite Archimedes game... :)
> Richard Murray provides an appraisal of various assemblers for RISC OS > machines here:http://www.heyrick.co.uk/assembler/apcsasm.html > I certainly disagree with his opinion that "ASM leaves objasm > standing", although no doubt someone will be along soon to say that I > have unfairly impugned ASM.
And extASM isn't even mentioned. Hrmmmf... :)
Granted, it's understandable, as hardly anyone knows about it, not at least because it has no (proper) homepage, and it hasn't been updated for over a decade, until recently.
Still, even at that time, it supported essentially a superset of the BASIC assembler functionality (including loops, conditional assembly, arbitrarily complex int/float/string expressions, etc.).
> > I know I could move onto C, but with the two competing environments > > out there, which one? GCC or Norcroft?
> If I'm quite honest, I don't think that time spent learning assembly > language in this day and age is time well spent (except perhaps for > the edification and amusement of enthusiasts).
I think that's enough justification, actually... :)
Besides, as mentioned in other posts, it's useful to know what is happening "at the bottom", even when using a high-level language. It could help to avoid or pinpoint performance problems, for example.
It can also help you understand how high-level programming languages work. For example, I had no problem understanding the "pointer" feature in C, after having done some assembly programming earlier: It's simply the address of a variable (or some other entity)... :)
I've heard that some have had great conceptual problems with understanding pointers, but that didn't happen to me...
> I made the transition from programming BASIC to programming in C > almost exactly ten years ago. At the time I was disappointed with the > poor performance of early programs that I wrote in C (which no doubt > used floating point arithmetic liberally). In retrospect I suppose I > was still in thrall to the proud claims on the packaging of Archimedes > games that they were '100% hand-optimised machine code' (as if that > were a good thing!). However, I have since realised that using > efficient and appropriate algorithms is far more important than the > choice of language used to implement them.
Also, nowadays, a compiler is typically able to do as least as good a job as an assembly programmer.
Still, there are some areas where I've found assembly programming to fit quite nicely, and an assembler is one of them. :) Assembly is good at "bit fiddling", and there's a lot of that in an assembler/ disassembler.
Still, if I were to write an assembler, today, I'd likely done it in C+ +, using the Spirit parser framework, or something like that, which would enable one to work at a higher level of abstraction, and leave more of the "boilerplate" to the compiler/library.
> If optimisation is required then an experienced C programmer can use > simple tricks like using automatic variables to avoid dereferencing a > pointer multiple times, whilst keeping in mind the limited number of > variable registers available within each function. (It is no faster to > load an automatic variable's value from the stack than it would be to > access a structure member by dereferencing a pointer, and the ARM has > already wasted time by copying that member's value to the stack!)
Here you are using your knowledge of assembly code to point out possible performance optimisations in C code... Was it still not time well spent learning...? ;)
> Great to hear from one of the authors (or maybe the author) of > Starfighter 3000, my favourite Archimedes game... :)
I'd like to take credit for that, but I really can't. All I did was hack the copy protection, fix lots of bugs, rewrite the sound player module, make the game code into a state machine, and bolt on a desktop interface. A huge amount of work, but not really the part that people appreciate. :-)
> > If optimisation is required then an experienced C programmer can use > > simple tricks like using automatic variables to avoid dereferencing a > > pointer multiple times, whilst keeping in mind the limited number of > > variable registers available within each function. (It is no faster to > > load an automatic variable's value from the stack than it would be to > > access a structure member by dereferencing a pointer, and the ARM has > > already wasted time by copying that member's value to the stack!)
> Here you are using your knowledge of assembly code to point out > possible performance optimisations in C code... Was it still not time > well spent learning...? ;)
You make a good point, although conceivably that kind of thing could be taught without knowledge of assembly language, by knowing certain features of the target architecture/PCS.
For example: 1) In each function a maximum of 6 fast temporary storage locations are available to hold automatic variables of type 'char', 'int', 'short int', 'long int' or 'void *'. 2) If too many automatic variables of the above types are declared then some will be held in slower temporary storage. 4) Using the '&' operator to get a pointer to an automatic variable forces it to be held in slower storage. 5) Automatic structures are always held in slower storage locations. 6) Calling a function or assigning to an l-value through a pointer invalidates any values previously accessed through pointers that might otherwise have been cached in fast temporary storage locations. ...etc
In message <23f71761-f389-49be-ac9e-407b2740b...@v25g2000yqk.googlegroups.com> chrisbaz...@bigfoot.com wrote:
> You make a good point, although conceivably that kind of thing could > be taught without knowledge of assembly language, by knowing certain > features of the target architecture/PCS.
One of my criteria for a good programming language is to what extent it allows the programmer a useful mental picture of what actually happens when the program runs - the operational semantics. No picture can be entirely accurate; it is a question of compromise. Assembly languages can be particularly useful educationally in this way. However, I think that particular architectures, adopted long in the past, tend to have a restricting influence on the choice of algorithms and datastructures that are encouraged by the languages influenced by them. C, for example, stems from the PDP11 era, when everything was based on buffers and pointers, as opposed, say to the use of hashing; so C promotes the mental picture that pointer values are actual addresses, as opposed to any fancier sort of descriptors that the compiled code may actually be using. I am not arguing that there is anything wrong with this, just that we can be lulled into making assumptions that may in some circumstances be limiting.
On Nov 5, 10:12 am, Terje Slettebø <tslett...@gmail.com> wrote:
> I agree with you about x86 vs ARM: I would never want to write x86 assembly code...
It's simply a case of what you're used to. Having been an x86 assembly language programmer for more than 20 years, I find it much easier to understand and program than ARM assembler. For me, thinking in terms of conditional instructions rather than conditional jumps is quite alien, requiring more of an intellectual leap from high-level programming.
It's true that the old 16-bit x86 was horrible to program, because of the asymmetrical nature of its instruction set (certain instructions only being able to use certain registers). Modern 32-bit IA-32 code is much nicer, because (with few exceptions) all the registers are equivalent.
I'm not qualified to comment on RISC OS, but on MS Windows using a hybrid of BBC BASIC and assembler is a very powerful technique. All my 'large' applications are written that way. In the case of games programming, David Williams' site illustrates the sort of thing the technique can achieve (you'll need a Windows PC to run the programs, but there are YouTube videos of some of them):
> On Nov 5, 10:12 am, Terje Slettebø <tslett...@gmail.com> wrote:
> > I agree with you about x86 vs ARM: I would never want to write x86 assembly code...
> It's simply a case of what you're used to. Having been an x86 > assembly language programmer for more than 20 years, I find it much > easier to understand and program than ARM assembler. For me, thinking > in terms of conditional instructions rather than conditional jumps is > quite alien, requiring more of an intellectual leap from high-level > programming.
> It's true that the old 16-bit x86 was horrible to program, because of > the asymmetrical nature of its instruction set (certain instructions > only being able to use certain registers). Modern 32-bit IA-32 code > is much nicer, because (with few exceptions) all the registers are > equivalent.
You're right, I guess it depends to a large extent on what you're used to, and also, x86 and ARM have become closer to each other: x86 has become more regularised, as you say (mostly, any register may be used for any instruction, and we don't have the horrible segmented memory system, anymore...), while ARM has grown quite a bit more complex (a lot more instructions).
Also, I understand what you mean about the conditional executed instructions. They take some getting used to, but once you've wrapped your head around them, they may lead to very succinct code (and eliminating many jumps). For example:
Certainly that is elegant and succinct, but there's no guarantee it will result in better performance or shorter code. For example, the most straightforward x86 equivalent (listed below) is exactly the same length (20 bytes) and, on modern processors with branch prediction, conditional jumps aren't expensive.
If you know in advance something about the statistics (for example you know that D is hardly ever 4) then doing that test first and bailing out if it fails may be more efficient than testing all four registers every time.
> Certainly that is elegant and succinct, but there's no guarantee it > will result in better performance or shorter code. For example, the > most straightforward x86 equivalent (listed below) is exactly the same > length (20 bytes) and, on modern processors with branch prediction, > conditional jumps aren't expensive.
The idea here for the ARM is that doing the above and not having branch prediction is a lot simpler for similar performance, and thus more power efficient. Doing the above for anything much more complex however doesn't win you anything, because it's cheaper to take the pipeline flush than execute all those no-ops. MIPS has an elegant, but quite confusing for new-comers approach to this; you have something called the branch delay slot. The instruction after a branch will be executed regardless; at this point, it's already made its way through half the pipeline, so you might as well finish it off.