Groups | Search | Server Info | Login | Register


Groups > comp.sys.acorn.programmer > #6559

Re: Learning ARM machine code

From Harriet Bazley <harriet@bazleyfamily.co.uk>
Newsgroups comp.sys.acorn.programmer
Subject Re: Learning ARM machine code
Date 2025-11-15 19:46 +0000
Organization A noiseless patient Spider
Message-ID <050c4e7c5c.harriet@bazleyfamily.co.uk> (permalink)
References (4 earlier) <iKm*CnCeA@news.chiark.greenend.org.uk> <5c2adc4465bavariasound@chiemgau-net.de> <5c2cea6fccbavariasound@chiemgau-net.de> <5c75805cc6bavariasound@chiemgau-net.de> <5c7c29dce9bavariasound@chiemgau-net.de>

Show all headers | View raw


On 15 Nov 2025 as I do recall,
          Alexander Ausserstorfer  wrote:

> In article <5c75805cc6bavariasound@chiemgau-net.de>,
>    Alexander Ausserstorfer <bavariasound@chiemgau-net.de> wrote:
> > In article <5c2cea6fccbavariasound@chiemgau-net.de>,
> >    Alexander Ausserstorfer <bavariasound@chiemgau-net.de> wrote:
> 
> > I discovered some interesting points. I will write about later here.
> 
> What I don't understand ist that: Bruce Smith wrotes in his book, that
> the command
> 
> MOV PC, R14
> 
> will stop your programme and jump back to RISC OS.
> 
> In machine code, it has the value &E1A0 E00F.
> 
> This is okey.
> 
> But when I use the Acorn Assembler (DDE) to translate this command (MOV
> PC, R14) to machine code (&E1A0 E00F) the result is much bigger as 4
> bytes!

If you want literal machine code I think you need to use the
instructions in the built-in BASIC assembler (or just enter the bytes
into a blank file, but that's a bit masochistic).

If you use external tools you are probably going to get all sorts of
file headers and so on being added;  filetype Absolute is defined an "an
absolute application loaded at &8000" rather than just a chunk of
machine code bytes.  As I understand it you can't double-click on pure
machine code -- you need to call it manually from within some program
that is already running.  It is too low-level to be able to set up all
the environment needed for a RISC OS task to start.

It's a very long time since I did any low-level programming, I'm afraid,
but here's the BASIC assembler set-up I have saved from my A5000 days:

REM StrongED$mode = BasAsm
ON ERROR: ON ERROR OFF: PRINT REPORT$;" at line ";ERL:END
length%=100
DIM ourcode% length%
L%=ourcode%+length%
PROCassemble
PRINT " Length of code = ";P%-ourcode%
PRINT " Block allocated = ";length%
PRINT " Now calling code "
LOCAL ERROR
ON ERROR LOCAL END
CALL ourcode%
END


DEF PROCassemble
REM implement two passes and set up
REM values for OPT at the same time
REM first pass - enable only range check
REM i.e. OPT 8
REM second pass - enable error report,
REM range check and listing, i.e. OPT 11
FOR pass% = 8 TO 11 STEP 3
 REM set P% to start of our code
 REM on each pass
 P% = ourcode%
 REM now invoke the assembler
 [OPT     pass%
 ; set value of OPT as appropriate
 ; assembler code will go here
MOV      R15, R14          ;exit routine
 ]
REM we have now left the assembler
NEXT pass%
ENDPROC

DEF FNmessage(string$)
[OPT pass%
   SWI    "OS_WriteS"
   EQUB   10
   EQUB   13
   EQUS   string$
   EQUB   10
   EQUB   13
   EQUB   0
]
=0

You can save this out as a BASIC file and double-click on it and it will
assemble and run whatever instructions you have entered between the
square brackets (take care not to exceed 100 bytes without increasing
length%, which defines the amount of space being reserved inside BASIC's
workspace for the code to be put into!)

If you want to actually use such a routine within a parent BASIC program
you can save out the relevant block of memory as a file of type Data and
then load it back into a  suitably dimensioned block of memory and CALL
that address, but to be honest it's generally easier to assemble scraps
of machine code using the inbuilt assembler when the parent program is
first run, because that way you can use BASIC variables, poke in text
values from variables, and so on, e.g. FNmessage here will store
the content of a string variable and the instruction to print it out.

So 
 [OPT     pass%
FNmessage("Harriet")
 MOV      R15, R14          ;exit routine
 ]

will generate a scrap of code that simply prints the string "Harriet".

-- 
Harriet Bazley                     ==  Loyaulte me lie ==

Time flies like an arrow - fruit flies like a banana

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-04-12 15:11 +0200
  Re: Learning ARM machine code Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-04-13 18:27 +0100
    Re: Learning ARM machine code Jean-Michel <jmc.bruck@orange.fr> - 2025-04-14 11:40 +0200
  Re: Learning ARM machine code Theo <theom+news@chiark.greenend.org.uk> - 2025-04-14 17:56 +0100
    Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-06-07 17:08 +0200
      Re: Learning ARM machine code Sebastian Barthel <naitsabes@freenet.de> - 2025-06-09 13:04 +0000
        Re: Learning ARM machine code Theo <theom+news@chiark.greenend.org.uk> - 2025-06-09 17:36 +0100
          Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-06-10 18:11 +0200
            Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-06-14 17:58 +0200
              Re: Learning ARM machine code Martin <News03@avisoft.f9.co.uk> - 2025-06-14 17:54 +0100
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-06-19 06:31 +0200
                Re: Learning ARM machine code Martin <News03@avisoft.f9.co.uk> - 2025-06-19 10:09 +0100
                Re: Learning ARM machine code Jean-Michel <jmc.bruck@orange.fr> - 2025-06-19 11:32 +0200
              Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-11-02 16:42 +0200
                Re: Learning ARM machine code Martin <News03@avisoft.f9.co.uk> - 2025-11-02 17:01 +0000
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-11-15 14:55 +0200
                Re: Learning ARM machine code druck <news@druck.org.uk> - 2025-11-17 19:08 +0000
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-11-15 15:11 +0200
                Re: Learning ARM machine code Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-11-15 19:46 +0000
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-12-06 17:57 +0200
                Re: Learning ARM machine code Martin <News04@avisoft.f9.co.uk> - 2025-12-06 18:15 +0000
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-12-07 16:25 +0200
                Re: Learning ARM machine code Martin <News04@avisoft.f9.co.uk> - 2025-12-07 15:57 +0000
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-12-21 17:13 +0200
                Re: Learning ARM machine code druck <news@druck.org.uk> - 2025-12-22 20:02 +0000
                Re: Learning ARM machine code Paul Sprangers <Paul@sprie.nl> - 2025-12-22 23:32 +0100
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2026-01-06 14:42 +0200
                Re: Learning ARM machine code anonymouse <na@ignoreme.com> - 2026-01-06 15:02 +0000
                Re: Learning ARM machine code Jean-Michel <jmc.bruck@orange.fr> - 2025-12-08 10:23 +0100
                Re: Learning ARM machine code Harriet Bazley <harriet@bazleyfamily.co.uk> - 2025-12-06 20:06 +0000
                Re: Learning ARM machine code druck <news@druck.org.uk> - 2025-12-09 08:21 +0000
                Re: Learning ARM machine code Martin <News04@avisoft.f9.co.uk> - 2025-12-09 09:48 +0000
                Re: Learning ARM machine code Richard Ashbery <basura@invalid.addr.uk> - 2025-12-09 10:54 +0000
                Re: Learning ARM machine code Steve Fryatt <news@stevefryatt.org.uk> - 2025-11-15 23:46 +0000
                Re: Learning ARM machine code Theo <theom+news@chiark.greenend.org.uk> - 2025-11-16 11:59 +0000
                Re: Learning ARM machine code Alexander Ausserstorfer <bavariasound@chiemgau-net.de> - 2025-12-06 18:10 +0200
                Re: Learning ARM machine code Steve Fryatt <news@stevefryatt.org.uk> - 2025-12-07 12:18 +0000
          Re: Learning ARM machine code Sebastian Barthel <naitsabes@freenet.de> - 2025-06-10 18:37 +0000

csiph-web