From c147726618da4f4c9ff835d41dd4dc21989ccde7 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 30 Nov 2018 17:53:17 +0100 Subject: Add rough untested implementation for b32d --- b32d.asm | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'b32d.asm') diff --git a/b32d.asm b/b32d.asm index aa7582b..1e17582 100644 --- a/b32d.asm +++ b/b32d.asm @@ -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 -- cgit v1.2.1