summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--b32e.asm22
-rw-r--r--makefile14
2 files changed, 21 insertions, 15 deletions
diff --git a/b32e.asm b/b32e.asm
index 8bab796..1e1b7a9 100644
--- a/b32e.asm
+++ b/b32e.asm
@@ -43,10 +43,12 @@ write_output:
b32e:
; save the number of bits read in cl
mov bl, 8 ; each byte contains 8 bits
- mul bl
+ mul bl ; multiply al by 8
mov cl, al
; set up output counter
xor r11, r11
+ ; set up processed bit counter
+ xor ch, ch
; initialize output buffer with padding
mov rbx, 0x3d3d3d3d3d3d3d3d
mov qword [output_buffer], rbx
@@ -70,21 +72,13 @@ b32e:
mov bl, byte [rbx]
mov byte [output_buffer + r11], bl
- ; increase counter
+ ; increase output counter
inc r11
+ ; increase bit counter
+ add ch, 5
- ; check number of bits converted >= bits read
- mov bl, 5 ; each iteration processed 5 bits
- mov rax, r11
- mul bl
- cmp al, cl
- jge .exit
-
- ; check counter
- ; when the counter reaches 8 it means that 8 characters (40 bits)
- ; have been processed and written
- cmp r11, 8
- jl .loop
+ cmp ch, cl
+ jl .loop
.exit:
ret
diff --git a/makefile b/makefile
index 6210d85..3b1e40c 100644
--- a/makefile
+++ b/makefile
@@ -2,7 +2,14 @@
all: b32e b32d
.PHONY: test
-test: b32e b32d
+test: b32e
+ echo "hello!" | ./b32e
+ @printf '\n'
+ echo "hello!" | base32 -w0
+ @printf '\n'
+
+.PHONY: ftest
+ftest: b32e b32d
cat makefile | ./b32e > makefile.b32
cat makefile | base32 -w 0 > makefile.check.b32
diff makefile.b32 makefile.check.b32
@@ -11,6 +18,11 @@ test: b32e b32d
@# cat makefile.check.b32 | base32 -d
diff makefile makefile.decoded
+.PHONY: perftest
+perftest: b32e
+ time cat doc/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf | ./b32e > 64-ia-32-intel2.pdf.b32
+ time cat doc/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf | base32 -w 0 > 64-ia-32-intel2.pdf.b32
+
# encoder
b32e: b32e.o
ld -o $@ $<