home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / code / asm_getf.sit < prev    next >
Encoding:
Text File  |  1988-05-14  |  9.0 KB  |  204 lines

  1. 11-May-88 21:22:52-MDT,9350;000000000000
  2. Return-Path: <u-lchoqu%sunset@cs.utah.edu>
  3. Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:22:34 MDT
  4. Received: by cs.utah.edu (5.54/utah-2.0-cs)
  5.     id AA03389; Wed, 11 May 88 21:23:07 MDT
  6. Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
  7.     id AA29235; Wed, 11 May 88 21:23:04 MDT
  8. Date: Wed, 11 May 88 21:23:04 MDT
  9. From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
  10. Message-Id: <8805120323.AA29235@sunset.utah.edu>
  11. To: rthum@simtel20.arpa
  12. Subject: GetFlags.asm
  13.  
  14. ;-----------------------------------------------------------------------------------
  15. ;
  16. ;     Procedure GetFlags(Flags: Integer;Var EachOne: Array[1..16] of Integer);
  17. ;
  18. ; This takes each of the bits of the Flags integer and loads them into the
  19. ;   EachOne array.
  20. ;
  21. ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  22. ;-----------------------------------------------------------------------------------
  23. ;
  24. XDEF        GetFlags
  25. GetFlags
  26.                 LINK    a6,#0            ; set frame pointer
  27.                 Move.l  8(a6),a0        ; get Address of array
  28.                 Move.w  12(a6),d0       ; Get Flags
  29.                 add.l   #32,a0            ; point past end
  30.                 moveq   #16,d1            ; set counter
  31. @1
  32.                 move.w  d0,-(a0)        ; load bits
  33.                 andi.w  #1,(a0)            ; leave only lowest bit
  34.                 ror.w   #1,d0            ; rotate bits right 1
  35.                 subq.w  #1,d1            ; decrement count
  36.                 BNE.s   @1
  37.                 unlk    a6            ; restore frame pointer
  38.                 move.l  (SP)+,a1        ; get return address
  39.                 add.w   #6,SP            ; pop parameters off stack
  40.                 JMP     (a1)            ; return
  41.  
  42. ;-----------------------------------------------------------------------------------
  43. ;
  44. ;     Procedure SetFlags(Var: Flags: Integer;EachOne: Array[1..16] of Integer);
  45. ;
  46. ; This takes the flags in the EachOne array (lowest bit of each) and loads the
  47. ;   flag word.
  48. ;
  49. ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  50. ;-----------------------------------------------------------------------------------
  51. ;
  52. XDEF        SetFlags
  53. SetFlags
  54.                 LINK    a6,#0            ; set frame pointer
  55.                 Move.l  8(a6),a0        ; get Address of array
  56.                 Move.l  12(a6),a1       ; Get Flags address
  57.                 moveq   #16,d1            ; set counter
  58.                 clr     d0            ; zero out the flags word
  59. @2
  60.                 rol.w   #1,d0            ; rotate left 1
  61.                 move.w  (a0)+,d2        ; get next flag word
  62.                 andi.w  #1,d2            ; get lowest bit
  63.                 or.w   d2,d0            ; stuff the bit
  64.                 subq.w  #1,d1            ; decrement count
  65.                 BNE.s   @2
  66.                 move.w  d0,(a1)            ; store result
  67.                 unlk    a6            ; restore frame pointer
  68.                 move.l  (SP)+,a1        ; get return address
  69.                 add.w   #8,SP            ; pop parameters off stack
  70.                 JMP     (a1)            ; return
  71.  
  72. ;-----------------------------------------------------------------------------------
  73. ;
  74. ;     Function IsFlgSet(Flags,index: Integer): Boolean;
  75. ;
  76. ; This returns true if the designated flag bit is set.
  77. ;
  78. ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  79. ;-----------------------------------------------------------------------------------
  80. ;
  81. XDEF        IsFlgSet
  82. IsFlgSet
  83.                 LINK    a6,#0            ; set frame pointer
  84.                 Move.w  8(a6),d1        ; Get index
  85.                 Move.w  10(a6),d0       ; Get Flags
  86.                 move.w  #16,d2            ;
  87.                 sub.w   d1,d2            ; get shift value
  88.                 ror.w   d2,d0            ; rotate bits right
  89.                 andi.w  #1,d0            ; wipe out the rest
  90.                 rol.w   #8,d0            ; shift result (boolean format)
  91.                 unlk    a6            ; restore frame pointer
  92.                 move.l  (SP)+,a1        ; get return address
  93.                 add.w   #4,SP            ; pop parameters off stack
  94.                 move.w  d0,-(SP)        ; put result on stack
  95.                 JMP     (a1)            ; return
  96.  
  97. ;-----------------------------------------------------------------------------------
  98. ;
  99. ;     Procedure SetAFlag(Var Flags: Integer; index: Integer);
  100. ;
  101. ; This sets one of the bits of the Flags word.
  102. ;
  103. ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  104. ;-----------------------------------------------------------------------------------
  105. ;
  106. XDEF        SetAFlag
  107. SetAFlag
  108.                 LINK    a6,#0            ; set frame pointer
  109.                 Move.w  8(a6),d0        ; get index
  110.                 Move.l  10(a6),a0       ; Get address of Flags
  111.                 move.w  #16,d2            ;
  112.                 sub.w   d0,d2            ; get shift value
  113.                 move.w  #1,d1            ; load a bit
  114.                 rol.w   d2,d1            ; rotate bit left
  115.                 or.w    d1,(a0)            ; Set the bit
  116.                 unlk    a6            ; restore frame pointer
  117.                 move.l  (SP)+,a1        ; get return address
  118.                 add.w   #6,SP            ; pop parameters off stack
  119.                 JMP     (a1)            ; return
  120.  
  121. ;-----------------------------------------------------------------------------------
  122. ;
  123. ;     Procedure ClrAFlag(Var Flags: Integer; index: Integer);
  124. ;
  125. ; This clears one of the bits of the Flags word.
  126. ;
  127. ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  128. ;-----------------------------------------------------------------------------------
  129. ;
  130. XDEF        ClrAFlag
  131. ClrAFlag
  132.                 LINK    a6,#0            ; set frame pointer
  133.                 Move.w  8(a6),d0        ; get index
  134.                 Move.l  10(a6),a0       ; Get address of Flags
  135.                 move.w  #16,d2            ;
  136.                 sub.w   d0,d2            ; get shift value
  137.                 move.w  #1,d1            ; load a bit
  138.                 rol.w   d2,d1            ; rotate bit left
  139.                 not.w   d1            ; complement
  140.                 and.w   d1,(a0)            ; Clear the bit
  141.                 unlk    a6            ; restore frame pointer
  142.                 move.l  (SP)+,a1        ; get return address
  143.                 add.w   #6,SP            ; pop parameters off stack
  144.                 JMP     (a1)            ; return
  145. ;-----------------------------------------------------------------------------------
  146. ;
  147. ;     Procedure GetANibl(InWord: Integer; Var value: Integer; index: Integer);
  148. ;
  149. ; This gets a nibble from an word.
  150. ;
  151. ; Written July 23, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  152. ;-----------------------------------------------------------------------------------
  153. ;
  154. XDEF        GetANibl
  155. GetANibl
  156.                 LINK    a6,#0            ; set frame pointer
  157.                 Move.w  8(a6),d1        ; get index
  158.                 Move.l  10(a6),a0       ; Get address of return value
  159.                 Move.w  14(a6),d0       ; Get Word
  160.                 move.w  #4,d2            ;
  161.                 muls    d2,d1            ; convert nibbles to bits
  162.                 move.w  #16,d2            ;       (or was that kibbles?)
  163.                 sub.w   d1,d2            ; get shift value
  164.                 ror.w   d2,d0            ; rotate bits right
  165.                 andi.w  #15,d0            ; wipe out the rest
  166.                 move.w  d0,(a0)            ; Store it
  167.                 unlk    a6            ; restore frame pointer
  168.                 move.l  (SP)+,a1        ; get return address
  169.                 add.w   #8,SP            ; pop parameters off stack
  170.                 JMP     (a1)            ; return
  171.  
  172. ;-----------------------------------------------------------------------------------
  173. ;
  174. ;     Procedure PutANibl(Var InWord: Integer; value,index: Integer);
  175. ;
  176. ; This writes out a nibble in a word.
  177. ;
  178. ; Written July 23, 1985 by Joseph F. Buchanan - University of Utah Computer Center
  179. ;-----------------------------------------------------------------------------------
  180. ;
  181. XDEF        PutANibl
  182. PutANibl
  183.                 LINK    a6,#0            ; set frame pointer
  184.                 Move.w  8(a6),d1        ; get index
  185.                 Move.w  10(a6),d0       ; Get value
  186.                 Move.l  12(a6),a0       ; Get address of Word
  187.                 move.w  #4,d2            ;
  188.                 muls    d2,d1            ; convert nibbles to bits
  189.                 move.w  #16,d2            ;       (or was that kibbles?)
  190.                 sub.w   d1,d2            ; get shift value
  191.                 move.w  #15,d1            ; load 4 mask bits
  192.                 not.w   d1            ; complement
  193.                 and.w   d1,d0            ; Keep only bottom nibble
  194.                 rol.w   d2,d1            ; rotate mask bits left
  195.                 and.w   d1,(a0)            ; Clear the nibble on destination
  196.                 rol.w   d2,d0            ; rotate value bits left
  197.                 or.w    d1,(a0)            ; Set the nibble bits
  198.                 unlk    a6            ; restore frame pointer
  199.                 move.l  (SP)+,a1        ; get return address
  200.                 add.w   #8,SP            ; pop parameters off stack
  201.                 JMP     (a1)            ; return
  202.  
  203.                 END
  204.