Embedded assembler in BBC BASIC
Scott Blackledge (3002) 2 posts |
I just bought “Raspberry Pi Assembly Language RISC OS Beginners” by Bruce Smith. This is my first exposure to the RISC OS and BBC BASIC. His book indicates that the assembler language you drop into is for the ARMv6 architecture. (I thought I skimmed over that the BASIC-supported assembly language is for ARMv5 but that is neither here nor there.) If his book is true, my wish would be to either support the ARMv8 architecture that the RPi 3 has Scott |
Jeffrey Lee (213) 6048 posts |
The current version of the inline assembler supports ARMv2-ARMv7. ARMv8 support will come eventually, but (in 32bit mode) the only additions you’re likely to want to use are the CRC instructions, so there isn’t a big rush. Note that BASIC doesn’t attempt to police what kinds of instruction you use; it’s your responsibility to make sure that you only use instructions which are supported on the target machine. The recently-added OS_PlatformFeatures 34 can help with this, as it returns many flags which indicate the availability of the different instruction groups that have been added/changed/removed since the ARM2. |
Scott Blackledge (3002) 2 posts |
Thanks, Jeffrey! How does the inline assembler know what architecture is being used (if nothing else then to create the correct machine code)? Scott |
Martin Avison (27) 1494 posts |
As Jeffrey said…
You have to ensure that the correct instructions are assembled for the target machine. Remember that you have the power of BASIC to help with this – it is an assembler with as many extra facilities as you code. |
Jeffrey Lee (213) 6048 posts |
It doesn’t need to know. Each new ARM architecture is (loosely) backwards compatible with the previous version. As long as you’re careful over which instructions you use it’s possible to create a binary that will run happily on both old and new machines.
It’s probably too trivial to be worth a bounty. ROOL like to keep the list short so that the money doesn’t get diluted too much. But having said that, a bounty did finish recently, so maybe they’ll add one or two new items sometime soon. |