On 08/02/10 20:18, john gilmore wrote:
Several--well 4--people have asked me off-list how the assembly-time 
construction of the table of one-bit counts can be automated.  Its manual 
construction by inspection is possible, though not I think advisable, for a 
table of the one-bit element counts for 0(1)255, which contains only 256 
values.  For a table of these counts for 0(1)65535, which contains 65536 
values, something else is required. ...


Here's mine; macro-free:

BITTAB   CSECT
TABLE    DC    65536AL1(*-TABLE-(*-TABLE)/2-(*-TABLE)/4-(*-TABLE)/8-(*-x
              TABLE)/16-(*-TABLE)/32-(*-TABLE)/64-(*-TABLE)/128-(*-TABx
              LE)/256-(*-TABLE)/512-(*-TABLE)/1024-(*-TABLE)/2048-(*-Tx
              ABLE)/4096-(*-TABLE)/8192-(*-TABLE)/16384-(*-TABLE)/3276x
              8)
        END

This [snipped] macro is "very inefficient", but notional compile-time 
inefficiency is a small price to pay for ensuring that a generated execution-time table 
is correct.  Readers who are unfamiliar with created set symbols will find it opaque but 
not unintelligible.  It is also an illustration of macro of the sort that mathematicians 
call a lemma: it is of no independent interest, and it does not itself generate code.  
Its function is instead to facilitate and simplify the work of another macro or macros 
that do generate code.


Which is opaquer is in the eye of the beholder.

-- gil
  • [no subject] john gilmore
    • Re: Assembler Coding Contest - new problem #22 Paul Gilmartin

Reply via email to