home *** CD-ROM | disk | FTP | other *** search
- 11-May-88 21:22:52-MDT,9350;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Wed, 11 May 88 21:22:34 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA03389; Wed, 11 May 88 21:23:07 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA29235; Wed, 11 May 88 21:23:04 MDT
- Date: Wed, 11 May 88 21:23:04 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8805120323.AA29235@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: GetFlags.asm
-
- ;-----------------------------------------------------------------------------------
- ;
- ; Procedure GetFlags(Flags: Integer;Var EachOne: Array[1..16] of Integer);
- ;
- ; This takes each of the bits of the Flags integer and loads them into the
- ; EachOne array.
- ;
- ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF GetFlags
- GetFlags
- LINK a6,#0 ; set frame pointer
- Move.l 8(a6),a0 ; get Address of array
- Move.w 12(a6),d0 ; Get Flags
- add.l #32,a0 ; point past end
- moveq #16,d1 ; set counter
- @1
- move.w d0,-(a0) ; load bits
- andi.w #1,(a0) ; leave only lowest bit
- ror.w #1,d0 ; rotate bits right 1
- subq.w #1,d1 ; decrement count
- BNE.s @1
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #6,SP ; pop parameters off stack
- JMP (a1) ; return
-
- ;-----------------------------------------------------------------------------------
- ;
- ; Procedure SetFlags(Var: Flags: Integer;EachOne: Array[1..16] of Integer);
- ;
- ; This takes the flags in the EachOne array (lowest bit of each) and loads the
- ; flag word.
- ;
- ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF SetFlags
- SetFlags
- LINK a6,#0 ; set frame pointer
- Move.l 8(a6),a0 ; get Address of array
- Move.l 12(a6),a1 ; Get Flags address
- moveq #16,d1 ; set counter
- clr d0 ; zero out the flags word
- @2
- rol.w #1,d0 ; rotate left 1
- move.w (a0)+,d2 ; get next flag word
- andi.w #1,d2 ; get lowest bit
- or.w d2,d0 ; stuff the bit
- subq.w #1,d1 ; decrement count
- BNE.s @2
- move.w d0,(a1) ; store result
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #8,SP ; pop parameters off stack
- JMP (a1) ; return
-
- ;-----------------------------------------------------------------------------------
- ;
- ; Function IsFlgSet(Flags,index: Integer): Boolean;
- ;
- ; This returns true if the designated flag bit is set.
- ;
- ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF IsFlgSet
- IsFlgSet
- LINK a6,#0 ; set frame pointer
- Move.w 8(a6),d1 ; Get index
- Move.w 10(a6),d0 ; Get Flags
- move.w #16,d2 ;
- sub.w d1,d2 ; get shift value
- ror.w d2,d0 ; rotate bits right
- andi.w #1,d0 ; wipe out the rest
- rol.w #8,d0 ; shift result (boolean format)
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #4,SP ; pop parameters off stack
- move.w d0,-(SP) ; put result on stack
- JMP (a1) ; return
-
- ;-----------------------------------------------------------------------------------
- ;
- ; Procedure SetAFlag(Var Flags: Integer; index: Integer);
- ;
- ; This sets one of the bits of the Flags word.
- ;
- ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF SetAFlag
- SetAFlag
- LINK a6,#0 ; set frame pointer
- Move.w 8(a6),d0 ; get index
- Move.l 10(a6),a0 ; Get address of Flags
- move.w #16,d2 ;
- sub.w d0,d2 ; get shift value
- move.w #1,d1 ; load a bit
- rol.w d2,d1 ; rotate bit left
- or.w d1,(a0) ; Set the bit
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #6,SP ; pop parameters off stack
- JMP (a1) ; return
-
- ;-----------------------------------------------------------------------------------
- ;
- ; Procedure ClrAFlag(Var Flags: Integer; index: Integer);
- ;
- ; This clears one of the bits of the Flags word.
- ;
- ; Written July 16, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF ClrAFlag
- ClrAFlag
- LINK a6,#0 ; set frame pointer
- Move.w 8(a6),d0 ; get index
- Move.l 10(a6),a0 ; Get address of Flags
- move.w #16,d2 ;
- sub.w d0,d2 ; get shift value
- move.w #1,d1 ; load a bit
- rol.w d2,d1 ; rotate bit left
- not.w d1 ; complement
- and.w d1,(a0) ; Clear the bit
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #6,SP ; pop parameters off stack
- JMP (a1) ; return
- ;-----------------------------------------------------------------------------------
- ;
- ; Procedure GetANibl(InWord: Integer; Var value: Integer; index: Integer);
- ;
- ; This gets a nibble from an word.
- ;
- ; Written July 23, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF GetANibl
- GetANibl
- LINK a6,#0 ; set frame pointer
- Move.w 8(a6),d1 ; get index
- Move.l 10(a6),a0 ; Get address of return value
- Move.w 14(a6),d0 ; Get Word
- move.w #4,d2 ;
- muls d2,d1 ; convert nibbles to bits
- move.w #16,d2 ; (or was that kibbles?)
- sub.w d1,d2 ; get shift value
- ror.w d2,d0 ; rotate bits right
- andi.w #15,d0 ; wipe out the rest
- move.w d0,(a0) ; Store it
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #8,SP ; pop parameters off stack
- JMP (a1) ; return
-
- ;-----------------------------------------------------------------------------------
- ;
- ; Procedure PutANibl(Var InWord: Integer; value,index: Integer);
- ;
- ; This writes out a nibble in a word.
- ;
- ; Written July 23, 1985 by Joseph F. Buchanan - University of Utah Computer Center
- ;-----------------------------------------------------------------------------------
- ;
- XDEF PutANibl
- PutANibl
- LINK a6,#0 ; set frame pointer
- Move.w 8(a6),d1 ; get index
- Move.w 10(a6),d0 ; Get value
- Move.l 12(a6),a0 ; Get address of Word
- move.w #4,d2 ;
- muls d2,d1 ; convert nibbles to bits
- move.w #16,d2 ; (or was that kibbles?)
- sub.w d1,d2 ; get shift value
- move.w #15,d1 ; load 4 mask bits
- not.w d1 ; complement
- and.w d1,d0 ; Keep only bottom nibble
- rol.w d2,d1 ; rotate mask bits left
- and.w d1,(a0) ; Clear the nibble on destination
- rol.w d2,d0 ; rotate value bits left
- or.w d1,(a0) ; Set the nibble bits
- unlk a6 ; restore frame pointer
- move.l (SP)+,a1 ; get return address
- add.w #8,SP ; pop parameters off stack
- JMP (a1) ; return
-
- END
-