Who said anything about more concise?
Personally, though, I'd do:
Code: Select all
DIM code 256
FOR A = 0 to 3 STEP 3
[ OPT A
EQUS "!dlroW ,olleH"
That's a little more concise, a little quicker and probably also a better illustration of how machine code works. The "start-1" and the string being stored reversed are the two slightly fiddly aspects.
To be clear: machine code is the collection of bytes the 6502 actually executes, the absolute lowest level software you can write on a BBC Micro. Assembly language is an at least slightly human-readable representation of that machine code.
When you run that BASIC program, it assembles a bit of machine code. You can CALL it immediately, but you could also store it away somewhere for later execution. The BASIC program is only needed to assemble it; you don't need it when you're running the machine code. You could, for example, assemble a sideways ROM, blow it into an EPROM, plug it into the computer then power-cycle.
So the assmbly code is verbose. But it produces 12 bytes of machine code, plus the string.
If, in BASIC, you write:
...that takes up 3 bytes for the line, 1 for PRINT, 1 for the space after PRINT, 2 for the open and close quotes. So 7 bytes. 12 bytes is still more than 7 bytes, but gives a rather more realistic impression of how relatively concise BASIC and machine code are.
In this particular case, the vast majority of the time is taken up in OSWRCH, the operating system code that displays a character on the screen. Whether it's called directly from machine code or indirectly by the BASIC interpreter. So don't expect the machine code to be much quicker. For a great many operations (including, for example, actually looking up the shape of the letter 'H', remembering which screen mode you're in, where the cursor is and what the current colours are, then printing that 'H' in red text on a blue background at position (4,2) in MODE 2) machine code will be many times faster than BASIC.
Plus it doesn't need the BASIC in order to run. This is especially important if what you're trying to write is the BASIC interpreter. (-8