NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: Siko7 on November 03, 2018, 10:32:09 AM
-
Hi Everyone
I would like to program a Base32 encoder. For this I have to split the binary data I get, into 5 bits and read them one after the other. What is the best way to solve this?
Unfortunately I am a beginner in assembly.
Thanks for helping
-
Perhaps for a beginner, you shouldn't write a "Base32 encoder" just yet. Show some code or else your question doesn't sound legit at all.
p/s Frank? ;D
-
Thanks dreamCoder,
I have to agree that a Base32 encoder does not sound like a good beginner project! Where do you stand, Siko7? Got an algorithm? I think I used to know what a Base32 encoder was, but that memory is paged out now. Sorry.
Best,
Frank
-
Here you can read what base32 is: https://en.wikipedia.org/wiki/Base32
For the moment i just have this code which is based on the hexdump code.
SECTION .data ; Section containing initialised data
Str: db " 00 00 00 00 00",10
BASELEN equ $-BASEStr
Digits: db "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
SECTION .bss ; Section containing uninitialized data
BUFFLEN equ 5 ; We read the file 5 bytes at a time
Buff: resb BUFFLEN ; Text buffer itself
StringOut db " ",10 ;
Stringoutlen equ $-StringOut
SECTION .text ; Section containing code
global _start ; Linker needs this to find the entry point!
_start:
Read:
mov eax,3 ; Specify sys_read call
mov ebx,0 ; Specify File Descriptor 0: Standard Input
mov ecx,Buff ; Pass offset of the buffer to read to
mov edx,BUFFLEN ; Pass number of bytes to read at one pass
int 80h ; Call sys_read to fill the buffer
mov ebp,eax ; Save # of bytes read from file for later
cmp eax,0 ; If eax=0, sys_read reached EOF on stdin
je Done ; Jump If Equal (to 0, from compare)