lundi 22 mars 2021

Attempting to use the syscall gettimeofday() to obtain a pseudorandom number in assembly on an armv7l , but registers go to 0 on syscall?

Once SWI #0 executes, r0 and the address represented by the label "time" do not have any value that's not null or garbage. I'm attempting to grab a single decimal number from the millisecond time value given from gettimeofday(2) syscall. This isn't intended to be cryptographically secure, and I'm constrained in terms of not being able use of the urandom file.

 timeofday:

    MOV r7, #78         @gettimeofday returns time
    LDR r0, =time       @address of holder for time_t
    MOV r1, #0          @timezone not needed
    SWI #0

_exit:
    MOV r7, #1         @exit syscall
    SWI #0

.data
time:   .space 8



Aucun commentaire:

Enregistrer un commentaire