Skip to content

Instantly share code, notes, and snippets.

@MightyPork
Created December 16, 2015 15:59
Show Gist options
  • Save MightyPork/145d0cff75c0c7dea3de to your computer and use it in GitHub Desktop.
Save MightyPork/145d0cff75c0c7dea3de to your computer and use it in GitHub Desktop.
<?php
$code = [
'A' => '01',
'B' => '1000',
'C' => '1010',
'D' => '100',
'E' => '0',
'F' => '0010',
'G' => '110',
'H' => '0000',
'I' => '00',
'J' => '0111',
'K' => '101',
'L' => '0100',
'M' => '11',
'N' => '10',
'O' => '111',
'P' => '0111',
'Q' => '1101',
'R' => '010',
'S' => '000',
'T' => '1',
'U' => '001',
'V' => '0001',
'W' => '011',
'X' => '1001',
'Y' => '1011',
'Z' => '1100',
'0' => '11111',
'1' => '01111',
'2' => '00111',
'3' => '00011',
'4' => '00001',
'5' => '00000',
'6' => '10000',
'7' => '11000',
'8' => '11100',
'9' => '11110',
];
foreach($code as $char => $code) {
echo ".db (".strlen($code) ." << 5) + 0b".$code . ", CHAR_$char\n";
//echo ".byte 0x" . dechex((strlen($code)<<5)+bindec($code)) . ", CHAR_$char\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment