67 lines
1.9 KiB
Text
67 lines
1.9 KiB
Text
.global _start
|
|
|
|
.text
|
|
_start:
|
|
bl rand20
|
|
adr x1, array
|
|
ldr x0, [x1, x0, LSL #3]
|
|
bl writez
|
|
adr x0, newline
|
|
bl writez
|
|
exit:
|
|
mov x8, #93
|
|
mov x0, xzr
|
|
svc #0
|
|
|
|
rand20:
|
|
sub sp, sp, #16
|
|
mov x0, sp
|
|
mov x1, #8
|
|
mov x2, xzr
|
|
mov x8, #278
|
|
svc #0
|
|
ldr x0, [sp], #16
|
|
mov x7, #20
|
|
mov x6, #-1
|
|
udiv x6, x6, x7
|
|
udiv x0, x0, x6
|
|
ret
|
|
|
|
writez: // extern long writez(char *str);
|
|
mov x1, x0 // address of str needs to be in x1 for syscall
|
|
sub x0, x0, #1 // decrement x0, because next statement increments it.
|
|
0: ldrb w2, [x0, #1]! // increment x0, load byte value at x0 in w2
|
|
cbnz w2, 0b // if w2 is not zero jump back to 0: label
|
|
sub x2, x0, x1 // subtract x1 from x0, load into x2. length of str
|
|
mov x0, #1 // mov into x0 1. stdout
|
|
mov x8, #64 // mov into x8 64. write
|
|
svc #0 // syscall
|
|
ret // return from function.
|
|
|
|
array: .quad str00, str01, str02, str03, str04
|
|
.quad str05, str06, str07, str08, str09
|
|
.quad str10, str11, str12, str13, str14
|
|
.quad str15, str16, str17, str18, str19
|
|
|
|
newline: .byte 0x0a, 0x00
|
|
str00: .asciz "It is certain!"
|
|
str01: .asciz "It is decidedly so."
|
|
str02: .asciz "Without a doubt."
|
|
str03: .asciz "Yes definitely."
|
|
str04: .asciz "You may rely on it."
|
|
str05: .asciz "As I see it, yes."
|
|
str06: .asciz "Most likely."
|
|
str07: .asciz "Outlook good."
|
|
str08: .asciz "Yes!"
|
|
str09: .asciz "Signs point to yes."
|
|
str10: .asciz "Reply hazy, try again."
|
|
str11: .asciz "Ask again later."
|
|
str12: .asciz "Better not tell you now."
|
|
str13: .asciz "Cannot predict now."
|
|
str14: .asciz "Concentrate and ask again."
|
|
str15: .asciz "Don't count on it."
|
|
str16: .asciz "My reply is no."
|
|
str17: .asciz "My sources say no."
|
|
str18: .asciz "Outlook not so good."
|
|
str19: .asciz "Very doubtful."
|
|
.align 4
|