home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / cfb / stipsparc.s < prev    next >
Encoding:
Text File  |  1991-06-12  |  5.9 KB  |  271 lines

  1. /*
  2.  * $XConsortium: stipsparc.s,v 1.6 91/06/12 17:03:24 keith Exp $
  3.  *
  4.  * Copyright 1990 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Keith Packard, MIT X Consortium
  24.  */
  25.  
  26. /*
  27.  * SPARC assembly code for optimized text rendering.
  28.  *
  29.  * Other stippling could be done in assembly, but the payoff is
  30.  * not nearly as large.  Mostly because large areas are heavily
  31.  * optimized already.
  32.  */
  33.  
  34. /* not that I expect to ever see an LSB SPARC, but ... */
  35. #ifdef LITTLE_ENDIAN
  36. # define BitsR        sll
  37. # define BitsL        srl
  38. # define BO(o)        o
  39. # define HO(o)        o
  40. # define WO(o)        o
  41. # define FourBits(dest,bits)    and    bits, 0xf, dest
  42. #else
  43. # define BitsR        srl
  44. # define BitsL        sll
  45. # define BO(o)        3-o
  46. # define HO(o)        2-o
  47. # define WO(o)        o
  48. # define FourBits(dest,bits)    srl    bits, 28, dest
  49. #endif
  50.  
  51. /*
  52.  * stipplestack(addr, stipple, value, stride, Count, Shift)
  53.  *               4       5       6      7     16(sp) 20(sp)
  54.  *
  55.  *  Apply successive 32-bit stipples starting at addr, addr+stride, ...
  56.  *
  57.  *  Used for text rendering, but only when no data could be lost
  58.  *  when the stipple is shifted left by Shift bits
  59.  */
  60. /* arguments */
  61. #define addr    %i0
  62. #define stipple    %i1
  63. #define value    %i2
  64. #define stride    %i3
  65. #define count    %i4
  66. #define shift    %i5
  67.  
  68. /* local variables */
  69. #define atemp    %l0
  70. #define bits    %l1
  71. #define lshift    %l2
  72. #define sbase    %l3
  73. #define stemp    %l4
  74.  
  75. #define CASE_SIZE    5    /* case blocks are 2^5 bytes each */
  76. #define CASE_MASK    0x1e0    /* first case mask */
  77.  
  78. #define ForEachLine    LY1
  79. #define NextLine    LY2
  80. #define CaseBegin    LY3
  81. #define ForEachBits    LY4
  82. #define NextBits    LY5
  83.  
  84. #ifdef TETEXT
  85. #define    _stipplestack    _stipplestackte
  86. #endif
  87.  
  88.     .seg    "text"
  89.     .proc    16
  90.     .globl    _stipplestack
  91. _stipplestack:
  92.     save    %sp,-64,%sp
  93.     sethi    %hi(CaseBegin),sbase        /* load up switch table */
  94.     or    sbase,%lo(CaseBegin),sbase
  95.  
  96.     mov    4,lshift            /* compute offset within */
  97.     sub    lshift, shift, lshift        /*  stipple of remaining bits */
  98. #ifdef LITTLE_ENDIAN
  99.     inc    CASE_SIZE, shift        /* first shift for LSB */
  100. #else
  101.     inc    28-CASE_SIZE, shift        /* first shift for MSB */
  102. #endif
  103.     /* do ... while (--count > 0); */
  104. ForEachLine:
  105.     ld    [stipple],bits            /* get stipple bits */
  106.     mov    addr,atemp            /* set up for this line */
  107. #ifdef TETEXT
  108.     /* Terminal emulator fonts are expanded and have many 0 rows */
  109.     tst    bits
  110.     bz    NextLine            /* skip out early on 0 */
  111. #endif
  112.     add    addr, stride, addr        /* step for the loop */
  113.     BitsR    bits, shift, stemp        /* get first bits */
  114.     and    stemp, CASE_MASK, stemp        /* compute first jump */
  115.     BitsL    bits, lshift, bits        /* set remaining bits */
  116.     jmp    sbase+stemp            /*  ... */
  117.     tst    bits
  118.  
  119. ForEachBits:
  120.     inc    4, atemp
  121. ForEachBits1:
  122.     FourBits(stemp, bits)            /* compute jump for */
  123.     sll    stemp, CASE_SIZE, stemp        /*  these four bits */
  124.     BitsL    bits, 4, bits            /* step for remaining bits */
  125.     jmp    sbase+stemp            /* jump */
  126.     tst    bits
  127. CaseBegin:
  128.     bnz,a    ForEachBits1            /* 0 */
  129.     inc    4, atemp
  130. NextLine:
  131.     deccc    1, count
  132.     bnz,a    ForEachLine
  133.     inc    4, stipple
  134.     ret
  135.     restore
  136.     nop
  137.  
  138.     bnz    ForEachBits            /* 1 */
  139.     stb    value, [atemp+BO(0)]
  140.     deccc    1, count
  141.     bnz,a    ForEachLine
  142.     inc    4, stipple
  143.     ret
  144.     restore
  145.     nop
  146.                     
  147.     bnz    ForEachBits            /* 2 */
  148.     stb    value, [atemp+BO(1)]
  149.     deccc    1, count
  150.     bnz,a    ForEachLine
  151.     inc    4, stipple
  152.     ret
  153.     restore
  154.     nop
  155.                     
  156.     bnz    ForEachBits            /* 3 */
  157.     sth    value, [atemp+HO(0)]
  158.     deccc    1, count
  159.     bnz,a    ForEachLine
  160.     inc    4, stipple
  161.     ret
  162.     restore
  163.     nop
  164.                     
  165.     bnz    ForEachBits            /* 4 */
  166.     stb    value, [atemp+BO(2)]
  167.     deccc    1, count
  168.     bnz,a    ForEachLine
  169.     inc    4, stipple
  170.     ret
  171.     restore
  172.     nop
  173.                     
  174.     stb    value, [atemp+BO(0)]        /* 5 */
  175.     bnz    ForEachBits
  176.     stb    value, [atemp+BO(2)]
  177.     deccc    1, count
  178.     bnz,a    ForEachLine
  179.     inc    4, stipple
  180.     ret
  181.     restore
  182.                     
  183.     stb    value, [atemp+BO(1)]        /* 6 */
  184.     bnz    ForEachBits
  185.     stb    value, [atemp+BO(2)]
  186.     deccc    1, count
  187.     bnz,a    ForEachLine
  188.     inc    4, stipple
  189.     ret
  190.     restore
  191.                     
  192.     sth    value, [atemp+HO(0)]        /* 7 */
  193.     bnz    ForEachBits
  194.     stb    value, [atemp+BO(2)]
  195.     deccc    1, count
  196.     bnz,a    ForEachLine
  197.     inc    4, stipple
  198.     ret
  199.     restore
  200.                     
  201.     bnz    ForEachBits            /* 8 */
  202.     stb    value, [atemp+BO(3)]
  203.     deccc    1, count
  204.     bnz,a    ForEachLine
  205.     inc    4, stipple
  206.     ret
  207.     restore
  208.     nop
  209.                     
  210.     stb    value, [atemp+BO(0)]        /* 9 */
  211.     bnz    ForEachBits
  212.     stb    value, [atemp+BO(3)]
  213.     deccc    1, count
  214.     bnz,a    ForEachLine
  215.     inc    4, stipple
  216.     ret
  217.     restore
  218.                     
  219.     stb    value, [atemp+BO(1)]        /* a */
  220.     bnz    ForEachBits
  221.     stb    value, [atemp+BO(3)]
  222.     deccc    1, count
  223.     bnz,a    ForEachLine
  224.     inc    4, stipple
  225.     ret
  226.     restore
  227.                     
  228.     sth    value, [atemp+HO(0)]        /* b */
  229.     bnz    ForEachBits
  230.     stb    value, [atemp+BO(3)]
  231.     deccc    1, count
  232.     bnz,a    ForEachLine
  233.     inc    4, stipple
  234.     ret
  235.     restore
  236.                     
  237.     bnz    ForEachBits            /* c */
  238.     sth    value, [atemp+HO(2)]
  239.     deccc    1, count
  240.     bnz,a    ForEachLine
  241.     inc    4, stipple
  242.     ret
  243.     restore
  244.     nop
  245.                     
  246.     stb    value, [atemp+BO(0)]        /* d */
  247.     bnz    ForEachBits
  248.     sth    value, [atemp+HO(2)]
  249.     deccc    1, count
  250.     bnz,a    ForEachLine
  251.     inc    4, stipple
  252.     ret
  253.     restore
  254.                     
  255.     stb    value, [atemp+BO(1)]        /* e */
  256.     bnz    ForEachBits
  257.     sth    value, [atemp+HO(2)]
  258.     deccc    1, count
  259.     bnz,a    ForEachLine
  260.     inc    4, stipple
  261.     ret
  262.     restore
  263.                     
  264.     bnz    ForEachBits            /* f */
  265.     st    value, [atemp+WO(0)]
  266.     deccc    1, count
  267.     bnz,a    ForEachLine
  268.     inc    4, stipple
  269.     ret
  270.     restore
  271.