简体   繁体   中英

Illegal Instruction ARM Assembly Raspberry Pi 4

I am trying assembly code for the first time on my Raspberry Pi 4 (sorry if the code isn't formatted in a standard way) and I am trying to execute my Hello World code

.global _start

_start:
mov r0, #1
ldr r1, =helloworld
mov r2, #12
mov r8, #64
svc 0
mov r0, #0
mov r8, #93
svc 0

.data
helloworld: .ascii "Hello World\n"

The code compiles with no errors but when I try to execute my code with./HelloWorld I get the arror "Illegal Instruction" with no other messages. Any ideas on what is going on?

You are using 64-bit system call numbers and ABI in a 32-bit assembly language, which is presumably in a 32-bit process which doesn't work.

Either put the 32-bit system call number in r7 (write = 4, exit = 1) or use 64-bit assembly language (different register names) in a 64-bit process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM