This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiling 32-bit arm code under 64-bit machine

Hello,

I am trying to run a very simple ARM code to print hello world on Google's Ampere CPU.
Code is written in 32-bit ARM and the system is 64-bit.

I use gnu-compiler from binutils and this is the error:

helloworld.s: Assembler messages:
helloworld.s:3: Error: operand 1 must be an integer register -- `mov R0,#1'
helloworld.s:4: Error: operand 1 must be an integer register -- `ldr R1,=message'
helloworld.s:5: Error: operand 1 must be an integer register -- `ldr R2,=len'
helloworld.s:6: Error: operand 1 must be an integer register -- `mov R7,#4'
helloworld.s:7: Error: unknown mnemonic `swi' -- `swi 0'
helloworld.s:9: Error: operand 1 must be an integer register -- `mov R7,1'
helloworld.s:10: Error: unknown mnemonic `swi' -- `swi 0'

Code is listed below:

.global _start
_start:
    MOV R0,#1
    LDR R1,=message
    LDR R2,=len
    MOV R7,#4
    SWI 0

    MOV R7, 1
    SWI 0


.data
message:
    .asciz "hello world \n"
len = .-message

I have installed 32-bit utils via sudo dpkg --add-architecture armhf but no success. I have also trued adding arguments as provided in this thread: https://github.com/ronny-nilsson/rpiburn/issues/1
N
o success again, architecture was not known. Probably due to different type of processor

If you have any tips, I would be very grateful if you can share them

Thank you

Samo