summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-11-30 17:53:17 +0100
committerNao Pross <naopross@thearcway.org>2018-11-30 17:53:17 +0100
commitc147726618da4f4c9ff835d41dd4dc21989ccde7 (patch)
treea0b911c01703b9b08f1fdacce7db98f3f4ffed72
parentUpdate test to show diff (diff)
downloadbase32asm-c147726618da4f4c9ff835d41dd4dc21989ccde7.tar.gz
base32asm-c147726618da4f4c9ff835d41dd4dc21989ccde7.zip
Add rough untested implementation for b32d
Diffstat (limited to '')
-rw-r--r--b32d.asm44
1 files changed, 42 insertions, 2 deletions
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