i have a programm in armv6 assembly which calculates the result of (x +y)^2
this code doesn't work, and returns: "Unsupported ARM syscall: 0xffffffdf"
.global _start
.text
_start:
MOV r0, #4
MOV r1, #5
MOV r7, #1
BL calc
SWI #0
calc:
ADD r7, r0, r1
MUL R0, R7, R7
MOV PC, LR
but this one is slightly edited and works (or it doesn't?):
.global _start
.text
_start:
MOV r0, #4
MOV r1, #5
MOV r7, #1
BL calc
BL exit
calc:
ADD r7, r0, r1
MUL R0, R7, R7
MOV PC, LR
exit:
LDR r7, =1
SWI 0
can anyone please tell me why the first code is not working? is the second one even valid?
First set
r0andr1:Setting
r7here has no effect:Call
calc:r7is now 4 + 5 = 9.Call system call number 9, which is
link:linkrequires 2 arguments which are pointers to strings, since neihter 81 nor 5 are valid pointers it returns the error-EFAULT= -14 inr0.r7is now -14 + 5 = -9 =0xfffffff7.Call system call number
0xfffffff7, which does not exist:The error
-ENOSYS= -38 is returned inr0.r7is now -38 + 5 = -33 =0xffffffdf.Call system call number
0xffffffdf, which does not exist:And this repeats indefinitely.
The correct program sets
r7to 1 beforeSWI 0so executes theexitsystem call.