So I'm trying to get the time using ARM assembly and am having trouble doing so. This is the code that I have:
.data
.balign 4
time:
.word 0
.text
.global _start
_start:
ldr r0, =time
mov r7, #0xd
svc #0
mov r7, #1
svc #0
However, when using GDB, the value at the address of the variable time is always 0. The return value in r0 after the first system call is always 0xffffffda. It never changes and I can assume that it isn't the time since epoch.
The information that I gathered this from is: https://w3challs.com/syscalls/?arch=arm_strong
I am trying to call the system call "time."
Note that I am programming on a Raspberry Pi 2 model B. The link links to arm_strong architecture and the architecture I am working with is an ARMv7. But essentially replacing the 9 with a 0 in the r7 requirement gets me the system call I want. So for "time" I use 0xd instead of 0x90000d.
What am I doing wrong that neither the return value nor the pointer I pass into the system call is getting me the value I expect? Eventually what I want to do is take the value and print it to the console.
-ENOSYS, which suggests it might be worth looking up the actual appropriate syscall number for the kernel version you're running, rather than guessing from a wildly out-of-date reference. - Notlikethattimeare because of runtime linking. Dynamic linker will populate them when your program is executed. - domentime_tfits in R0 and you can use it directly. Can you do that and see if the error code changes? Or you are successful. You could use the Linux 'asm/unistd.h' and get the 0xd constant from there as__NR_time(and__NR_exittoo). The issue may have to do with the constant pool and data references. You might want to set an exit code. I guess the executable runs with out SEGV? - artless noise