summaryrefslogblamecommitdiff
path: root/pasmgen.inc
blob: 95fadb7351d876cfa0a62665abe79e809bb05a6a (plain) (tree)






















































                                                                 
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