home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / ibm8514 / blkout.s next >
Text File  |  1991-09-20  |  3KB  |  102 lines

  1.     .file    "blkout.s"
  2. /* $Id: blkout.s,v 1.1 1991/09/20 19:10:24 mtranle Exp $ */
  3. /*                                    */
  4. /*    void                                */
  5. /*    blockoutw( unsigned short *values, int n )            */
  6. /*                                    */
  7. /*    This routine destroys the contents of %eax, %ecx & %edx        */
  8. /*    All other registers are preserved.                */
  9. /*                                    */
  10.  
  11.     .def    blockoutw;    .val    blockoutw;
  12.     .scl    2;    .type    055;    .endef
  13.     .globl    blockoutw
  14. .align 4
  15.     movw    %ax, %ax    /* Aligning "nop" */
  16. blockoutw:
  17.     xchgl    %esi, 4(%esp)    /* get "values" */
  18.     xchgl    %ebx, 8(%esp)    /* get "n" */
  19. /* Bottom half of %edx is I/O addr of the queue status port    0xDAE8 */
  20. /* Top half of %edx is I/O addr of the variable-data port    0xE2E8 */
  21.     movl    $0xE2E8DAE8, %edx
  22.  
  23. .testQ1:    /* Now %dx points to the queue status port */
  24.     inw    (%dx)        /* Read The Queue Status Port */
  25.     xorb    $0xFF, %al    /* same as logical negation, but set flags */
  26.     jz    .testQ1        /* If no slots are available, spin & burn */
  27.  
  28.     bsfl    %eax, %ecx
  29.     rorl    $16, %edx    /* Point %dx at the VAR-DATA I/O port */
  30.     subb    $8, %cl        /* The number of empty slots -- NEGATED !! */
  31.     negb    %cl        /* The number of empty slots !! */
  32.     subl    %ecx, %ebx    /* The number of words remaining after this */
  33.     jle    .final_batch
  34.     rep
  35.     outsw    /* (%dx), (%esi) */
  36.     rorl    $16, %edx    /* Point %dx at the Queue Status I/O port */
  37.     jmp    .testQ1
  38.  
  39. .final_batch:
  40.     add    %ebx, %ecx    /* The number of words left !! */
  41.     jz    .done1        /* Are there any words left ?? */
  42.     rep
  43.     outsw    /* (%dx), (%esi) */
  44. .done1:
  45.     movl    4(%esp), %esi
  46.     movl    8(%esp), %ebx
  47.     ret
  48.     .def    blockoutw;    .val    .;    .scl    -1;    .endef
  49.  
  50. /*    void                    */
  51. /*    blockouttransmogrifiedw( values, n )    */
  52. /*    register unsigned char *values    ;    */
  53. /*    register int n ;            */
  54. /*    {                    */
  55. /*    register unsigned char tmp ;        */
  56. /*                        */
  57. /*    do {                    */
  58. /*        tmp = *values++ ;        */
  59. /*        tmp = transmogrify( tmp ) ;    */
  60. /*        ibm8514CheckQueue( 1 ) ;    */
  61. /*        outw( VARDATA, tmp ) ;        */
  62. /*    } while ( --n ) ;            */
  63. /*    return    ;                */
  64. /*    }                    */
  65.     /* .align    4 */ /* Better off without this !! */
  66.     .def    blockouttransmogrifiedw;    .val    blockouttransmogrifiedw;
  67.     .scl    2;    .type    055;    .endef
  68.     .globl    blockouttransmogrifiedw
  69.     .text
  70. blockouttransmogrifiedw:
  71.     xchgl    0x4(%esp), %esi
  72.     movl    0x8(%esp), %ecx
  73.     jcxz    .done2
  74. /* Top half of %edx is I/O addr of the queue status port    0xDAE8 */
  75. /* Bottom half of %edx is I/O addr of the variable-data port    0xE2E8 */
  76.     movl    $0xDAE8E2E8, %edx
  77. .Loop_Top:
  78.     rorl    $16, %edx
  79. /*        do { */
  80. .testQ2:        /* ibm8514CheckQueue( 1 ) ;    */
  81. /*        ibm8514CheckQueue( 1 ) ;    */
  82.     inw    (%dx)        /* Read The Queue Status Port */
  83.     testb    $128, %al
  84.     jnz    .testQ2
  85.     lodsb        /* tmp = *values++ ; ---- Does Increment For Us !! */
  86. /*        tmp = transmogrify( tmp ) ;    */
  87.     shll    $4, %eax
  88.     shrb    $4, %al
  89.     addl    %eax, %eax
  90.     xchgb    %ah, %al
  91. /*        outw( VARDATA, tmp ) ;        */
  92.     rorl    $16, %edx
  93.     outw    (%dx)
  94. /*    } while ( --n ) ;            */
  95.     loop    .Loop_Top
  96. .done2:
  97.     movl    0x4(%esp), %esi
  98.     ret
  99.     
  100.     .def    blockouttransmogrifiedw;    .val    .;
  101.     .scl    -1;    .endef
  102.