I'm currently working on an assembly project right now and I have to generate a random number. So far I've managed to write some code that should work, but I don't think is working beacuse it does not print the random number. My code is this:
/*--random01.s*/
.data
.balign 4
mensaje1: .asciz "Random \n"
.balign 4
return: .word 0
.text
.global main
main:
ldr r1, addr_of_return
str lr, [r1]
ldr r0, addr_of_msg1
bl printf
tst r1,r1, lsr #1
movs r2,r0, rrx
adc r1,r1, r1
eor r2,r2, r0, lsl #12
eor r0,r2, r2, lsr #20
ldr r0, [r0]
bl printf
ldr lr, addr_of_return
ldr lr, [lr]
bx lr
addr_of_msg1: .word mensaje1
addr_of_return: .word return
.global printf
My question is, how can I achieve the generation of a random number? Am I doing this right or should I try working with the clock?
Aucun commentaire:
Enregistrer un commentaire