# Datamaker

``` BBS: Inland Empire Archive
Date: 07-06-92 (07:06)             Number: 292
From: AARON WEST                   Refer#: NONE
To: MARK BUTLER                   Recvd: NO
Subj: Datamaker                      Conf: (2) Quik_Bas```
```MB> JV> The trick is in bit shifting..  3 bytes become 4 and........
MB> JV> .............<post partially abridged>.......................
MB> JV> To split 24 bits into 4 six bit numbers, I think you'd divide by
MB> JV> 2^18, then 2^12, then 2^6 , then.............................

MB> Hey, you're on the case now buddy! If you get that conversion formula
MB> worked out it'll be all downhill from there! <grin>

From the author of the 'automagic' (not my name, but maybe I'll use it!)
self-uudecoder:

Here's a fragment from makeuue.c, in the comment section:
Given:
7654321.7654321.7654321.
54321.54321.54321.54321.
c1=byte1, c2=byte2, c3=byte3:
o1=c1>>2; o2=(c1&3)<<4+c2>>4; o3=(c2&15)<<2+c3>>6; o4=c3&63;

OK, in BASIC (binary to UUE):

l2\$=""
for i=1 to len(lin\$) step 3
c1=asc(mid\$(lin\$,i,1))
c2=asc(mid\$(lin\$,i+1,1))
c3=asc(mid\$(lin\$,i+2,1))
l2\$=l2\$+chr\$(c1\4)+chr\$((c1 and 3)*16+(c2\16))
l2\$=l2\$+chr\$((c2 and 15)*4+c3\64)+chr\$(c3 and 63)
next i

The reverse (UUE to binary), converted to basic:

;get 4 bytes, put in msb-lsb order
;         t0      t1      t2      t3
;         al      ah      al      ah
;input..543210..543210..543210..543210
;output 765432--107654--321076--543210
;           b0        b1        b2

c1=(asc(mid\$(lin\$,i,1))-32)and 63
...
c4=(asc(mid\$(lin\$,i+3,1))-32)and 63

l2\$=l2\$+chr\$(c1*4+c2\64)+chr\$((c2*16 and &HF0)+c3\4)
l2\$=l2\$+chr\$((c3*64 and &HC0)+c4)

Phew, took a few minutes to do in my head!

* SLMR 2.1a * Press <CTRL>-<ALT>-<DEL> to continue ...

--- Maximus 2.00
* Origin: Hartford Metro Area BBS (1:142/911)
```

Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET