diff options
author | Nao Pross <naopross@thearcway.org> | 2018-11-30 17:53:17 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-11-30 17:53:17 +0100 |
commit | c147726618da4f4c9ff835d41dd4dc21989ccde7 (patch) | |
tree | a0b911c01703b9b08f1fdacce7db98f3f4ffed72 | |
parent | Update test to show diff (diff) | |
download | base32asm-c147726618da4f4c9ff835d41dd4dc21989ccde7.tar.gz base32asm-c147726618da4f4c9ff835d41dd4dc21989ccde7.zip |
Add rough untested implementation for b32d
Diffstat (limited to '')
-rw-r--r-- | b32d.asm | 44 |
1 files changed, 42 insertions, 2 deletions
@@ -33,13 +33,53 @@ write_output: ret ; b32d -; decodes 8 RFC4648 characters without checking its validity (!!!) -; uses reg: +; decodes 8 RFC4648 characters (without checking its validity!) +; uses reg: rax, rbx ; uses mem: input_buffer, output_buffer b32d: + ; reset rax (output) + xor rax, rax + ; set downwards counter + mov bl, 8 + +.loop: + ; get a character + mov bh, byte [output_buffer] + ; if is padding, exit + cmp bh, 0x3d + je .exit + + ; shift rax of one byte + shl rax, 5 + ; insert the new 5 bits + or al, bh + + ; decrement counter + dec bl + jnz .loop + +.exit: + ; save output + mov [input_buffer], rax ret + _start: + nop + +.loop: + ; read input + call read_input + ; read nothing + cmp rax, 0 + je .exit + + ; decode base32 + call b32d + ; print + call write_output + jmp .loop + .exit: ; linux x64 exit(0) mov rax, 60 |