1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
macro genclass class, class_len
{
;; Generate 16 bits (smallest) of randomness from the cpu
rdrand ax
;; Modulo into len range to index in
xor rdx, rdx
mov rbx, class_len
div bx
;; Save output letter into out_buf, bump rcx
add rdx, class
mov rdx, [rdx]
mov [rcx], rdx
inc rcx
inc rsi
}
generate:
;; Store which output byte we're up to in rcx
mov rcx, out_buf
;; Store chars generated in rsi
xor rsi, rsi
tripleter:
genclass consonants, consonants_len
genclass vowels, vowels_len
genclass consonants, consonants_len
dec r8
test r8, r8
jnz tripleter
symboler:
genclass symbols, symbols_len
dec r9
test r9, r9
jnz symboler
numberer:
genclass numbers, numbers_len
dec r10
test r10, r10
jnz numberer
;; Append new line to string
mov [rcx], word 10
inc rsi
;; Special case to caps the first character
xor rax, rax
mov al, byte [out_buf]
sub al, 32
mov rbx, out_buf
mov [rbx], al
jmp ok
|