diff options
author | Nicholas Tay <nick@windblume.net> | 2023-10-22 18:52:36 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2023-10-22 18:52:36 +1100 |
commit | 0f70ee2fc5195deeb6c3d97b57e0c6ee40f421bb (patch) | |
tree | d997ec566e934baff34a47a13dd843057e5a5706 /pasmgen.asm | |
download | pasmgen-0f70ee2fc5195deeb6c3d97b57e0c6ee40f421bb.tar.gz pasmgen-0f70ee2fc5195deeb6c3d97b57e0c6ee40f421bb.tar.bz2 pasmgen-0f70ee2fc5195deeb6c3d97b57e0c6ee40f421bb.zip |
Initial working 3/2/3 passgen in fasm
Diffstat (limited to '')
-rw-r--r-- | pasmgen.asm | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/pasmgen.asm b/pasmgen.asm new file mode 100644 index 0000000..bbd4c37 --- /dev/null +++ b/pasmgen.asm @@ -0,0 +1,78 @@ +format ELF64 executable + +macro genclass class, class_len, caps +{ + ;; 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] + if caps eq 1 + sub rdx, 32 + end if + mov [rcx], rdx + inc rcx + + inc rsi +} + +macro triplet +{ + genclass consonants, consonants_len + genclass vowels, vowels_len + genclass consonants, consonants_len +} + +segment readable executable + +entry main +main: + ;; Store which output byte we're up to in rcx + mov rcx, out_buf + ;; Store chars generated in rsi + xor rsi, rsi + + genclass consonants, consonants_len, 1 + genclass vowels, vowels_len + genclass consonants, consonants_len + triplet + triplet + genclass symbols, symbols_len + genclass symbols, symbols_len + genclass numbers, numbers_len + genclass numbers, numbers_len + genclass numbers, numbers_len + + mov [rcx], word 10 + inc rsi + + ;; Write + mov rdi, 1 ;; stdout + mov rdx, rsi + mov rsi, out_buf + mov rax, 0x01 + syscall + + ;; Exit (code 0) + mov rdi, 0 + mov rax, 0x3c + syscall + +segment readable writeable + +numbers db "0123456789" +numbers_len = $ - numbers +vowels db "aeiou" +vowels_len = $ - vowels +consonants db "bcdfghjklmnpqrstvwxyz" +consonants_len = $ - consonants +symbols db "!@#$%&()-=_+[]{}\\|;<>/?." +symbols_len = $ - symbols + +out_buf rb 32 |