Bitstream Generator Source Code Test Program


URI:

http://herbert.gandraxa.com/herbert/bst_test.asp

Link template:   

<a href="http://herbert.gandraxa.com/herbert/bst_test.asp">Bitstream Generator Source Code Test Program</a>


Link symbols:   

Local LinkOn current page | DocumentOn this site | External PageOn external site | WikipediaWikipedia article | Compressed ArchiveZIP archive | PDF documentPDF | E-MailE-Mail


Article

Organization

DocumentHome » DocumentLinoleum Source Code » DocumentBitstream Generator » Source Code Test Program

Scope

This is the source code of the Bitstream Generator Test Program, testing the Bitstream Generator library, implemented in the WikipediaLinoleum programming language.

Author

DocumentHerbert Glarner


Usage

This test program tests long-term functionality of the DocumentBitstream Generator library.

Make sure you have the library named bst.txt in the same folder as this test program before assembling the latter.

If compiling this test as is, you will need a test file, residing in the same directory. I used a publically available e-book ("Pygmalion" from G. B. Shaw). You can find it at the WikipediaProject Gutenberg (check copyright legislation for your country).

Run the assembled exe.


Source Code

(Test application, using the BST Library Routines "BST.txt".)

(On a 1,328 MHz P4, a file with PSW=8, i.e. organized in bytes, performs as
follows:    Creating a bitstream with PSW=7: 285 million bits/second
            Creating a bitstream with PSW=8: 335 million bits/second
including required bytes rotation because of performing the test on a 
Little Endian system.)

(*****************************************************************************)
"libraries"

    (=========================================================================)
    (Bitstream.)
    (-------------------------------------------------------------------------)
    (The library which is tested with this test program.)
    (-------------------------------------------------------------------------)
        BST;
    (=========================================================================)

(*****************************************************************************)
"directors"
        program name = { BST File Test };
        unit = 32;

(*****************************************************************************)
"constants"                             (Convention: "BST ...", UPPER CASE)

    (=========================================================================)
    (The testfile is 208,420 bytes long. It is read in 100 times. Each copy is
    concatenated to the previous one to form a 100 times as long mega-book; a
    single copy would process too fast to be measurable accurately.)
    (-------------------------------------------------------------------------)
        BST FILENAME READINGS = 100;
        BST FILENAME SIZE = 208 420 div 4 mtp BST FILENAME READINGS ;
    (=========================================================================)

(*****************************************************************************)
"variables"                             (Convention: "bst ...", lower case)

    (=========================================================================)
    (The file is 'Pygmalion.txt' by George Bernard Shaw. The text was retrieved
    from 'Project Gutenberg' at address:
    'http://www.gutenberg.org/dirs/etext03/pygml10.txt'
    Check copyright notices there.)
    (-------------------------------------------------------------------------)
        bst test filename = { pygml10.txt };
    (=========================================================================)

(*****************************************************************************)
"workspace"                             (Convention: "bst ...", lower case)

    (=========================================================================)
    (Space for reading a large file and space for the output bitstream)
    (-------------------------------------------------------------------------)
    (The 'plus 1' ensures, that there is a Null-byte, actually four of them,
    after the last byte of the copies.)
        bst test inputfile = BST FILENAME SIZE plus 1;
        bst test bitstream = BST FILENAME SIZE plus 1;
    (=========================================================================)

(*****************************************************************************)
"programme"                             (Convention: "Bst ...", Mixed case)


    (=========================================================================)
    (Reading in a testfile. It contains 8 bit ASCII characters. There are
    208,420 bytes in the file. Note, that the original contains 2 bytes more:
    the last CR/LF symbols were removed to make the file's size evenly divisible
    by 4 in order to allow a multiple concatenation of the same file on unit
    boundaries.)
    (-------------------------------------------------------------------------)
    (Check if file exists)
        [File Name] = bst test filename;
        [File Command] = TEST;
        isocall;
        ? ok -> bst test file found;
        [bst error] = 100000;
        -> Bst Test Error;
    "bst test file found"
    (-------------------------------------------------------------------------)
    (Check if we may read the file)
        ? [File Status] + PERMIT TO READ -> bst test file readable;
        [bst error] = 100001;
        -> Bst Test Error;
    "bst test file readable"
    (-------------------------------------------------------------------------)
    (The testfile is read in 100 times. Each copy is concatenated to the
    previous one to form a 100 times as long mega-book; a single copy would
    simply process too fast to be measurable accurately.)
        A = BST FILENAME READINGS;          (We read the file multiple times)

        [File Name] = bst test filename;
        [Block Pointer] = bst test inputfile;
    "bst test read it again"
    (-------------------------------------------------------------------------)
    (Read the file into the workspace area 'bst test inputfile'.)
        [File Command] = READ;
        [File Position] = ZERO;
        [Block Size] = BST FILENAME SIZE mtp BYTESPERUNIT;
        isocall;
    (-------------------------------------------------------------------------)
    (The file's bytes are evely divisible by 4.)
        B = [Block Size];                   (Block size is in byte)
        B > 2;                              (We want units)
        [Block Pointer] + B;                (Address for next duplicate)
        A ^ bst test read it again;         (read the book again)
    (=========================================================================)


    (=========================================================================)
    (Initialising a bitstream area.)
    (-------------------------------------------------------------------------)
        A = 8;                      (PSW: Characters are in 8 bit units)
        B = 7;                      (LSW: ASCII characters have 7 bits per char)
        C = 0;                      (End of symbols EOS is NUL-terminator)
        => Bst Init;
        ? failed -> Bst Test Error;

    (When reading in 'Big Endian' files, or also when processing Linoleum
    strings, set the following variable. When reading in ordinary 'Little
    Endian' files, as produced by Intel by default, do not set the flag!)
        ([bst status] | BST BIG ENDIAN;)
    (=========================================================================)


    (=========================================================================)
    (Starting to measure the bitstreaming process of the mega-book, i.e. all
    the concatenated copies.)
    (-------------------------------------------------------------------------)
        [TimerCommand] = READ COUNTS;
        isocall;
        A = [Counts];
    (=========================================================================)


    (=========================================================================)
    (Creating a bitstream for above variables.)
    (-------------------------------------------------------------------------)
        E = bst test inputfile;
        D = bst test bitstream;
        => Bst Stream;
    (=========================================================================)


    (=========================================================================)
    (Measuring the bitstreaming process of the mega-book, i.e. all
    the concatenated copies.)
    (-------------------------------------------------------------------------)
        [TimerCommand] = READ COUNTS;
        isocall;
        A - [Counts]; A +-;
        B = [Counts Per Millisecond];

    (Comment the following, if interested in number of bits and first 3 units,
    uncomment, if interested in the time.)
        show registers;
    (=========================================================================)


    (=========================================================================)
    "Bst Test Ok"
    (Ending without errors)
        B = 0;
        -> Bst Test Quit;
    (-------------------------------------------------------------------------)
    "Bst Test Error"
        B = [bst error];
        (-> Bst Test Quit;)
    (-------------------------------------------------------------------------)
    "Bst Test Quit"
    (Number of streamed out bits in A)
        A = [bst bits];
    (C, D and E take the three first outstream units)
        C = [bst test bitstream];
        D = [bst test bitstream plus 1];
        E = [bst test bitstream plus 2];
    (-------------------------------------------------------------------------)
    (Registers:
        A:   Number of streamed out bits. If reading in the provided testfile
             of 208,420 bytes and streaming into 7 bit ASCII, this will read
             7 * 208,420 = 1,458,940 bits per copy. If streaming into 8 bits,
             this should be 8 * 208,420 = 1,667,360 bits per copy.
        B:   Error code, 0 if no errors occured. For other values see the
             BST ERR XXX constants, given in the BST library.
        C-E: Content of the first 3 outstream units, i.e. the first 96 bits.

             For 7 bit, these will be:
                C 2846042634d
                  1010100 1101000 1100101 0100000 1010...
                  'T'     'h'     'e'     ' '     'P'

                D 0481815243d
                  ...000 1110010 1101111 1101010 1100101 1...
                         'r'     'o'     'j'     'e'     'c'

                E 2409761021d
                  ...100011 1110100 0100000 1000111 11101...
                            't'     ' '     'G'
                 That is, the string {The Project G}, which are the initial
                 symbols within the test file.

             For 8 bit, the result should read:
                C 1416127776d
                  01010100 01101000 01100101 00100000
                  'T'      'h'      'e'      ' '
                D 1349676906d
                  01010000 01110010 01101111 01101010
                  'P'      'r'      'o'      'j'
                E 1701016608d
                  01100101 01100011 01110100 00100000
                  'e'      'c'      't'      ' '
    )
        show registers;
    (=========================================================================)


(*****************************************************************************)

Linoleum Syntax Highlighting produced with LSH (© 2007 by Herbert Glarner)