home *** CD-ROM | disk | FTP | other *** search
/ Openstep 4.2 (Developer) / Openstep Developer 4.2.iso / NextDeveloper / Source / GNU / cctools / include / architecture / nrw / reg_help.h < prev   
Encoding:
C/C++ Source or Header  |  1993-01-04  |  1.2 KB  |  42 lines

  1. /* Copyright (c) 1991 NeXT Computer, Inc.  All rights reserved.
  2.  *
  3.  *    File:    architecture/nrw/reg_help.h
  4.  *    Author:    Mike DeMoney, NeXT Computer, Inc.
  5.  *
  6.  *    This header file defines cpp macros useful for defining
  7.  *    machine register and doing machine-level operations.
  8.  *
  9.  * HISTORY
  10.  * 23-Jan-91  Mike DeMoney (mike@next.com)
  11.  *    Created.
  12.  */
  13.  
  14. #ifndef    _NRW_REG_HELP_H_
  15. #define    _NRW_REG_HELP_H_
  16.  
  17. /* Bitfield definition aid */
  18. #define    BITS_WIDTH(msb, lsb)    ((msb)-(lsb)+1)
  19. #define    BIT_WIDTH(pos)        (1)    /* mostly to record the position */
  20.  
  21. /* Mask creation */
  22. #define    MKMASK(width, offset)    (((unsigned)-1)>>(32-(width))<<(offset))
  23. #define    BITSMASK(msb, lsb)    MKMASK(BITS_WIDTH(msb, lsb), lsb & 0x1f)
  24. #define    BITMASK(pos)        MKMASK(BIT_WIDTH(pos), pos & 0x1f)
  25.  
  26. /* Register addresses */
  27. #if    __ASSEMBLER__
  28. # define    REG_ADDR(type, addr)    (addr)
  29. #else    __ASSEMBLER__
  30. # define    REG_ADDR(type, addr)    (*(volatile type *)(addr))
  31. #endif    __ASSEMBLER__
  32.  
  33. /* Cast a register to be an unsigned */
  34. #define    CONTENTS(foo)    (*(unsigned *) &(foo))
  35.  
  36. /* STRINGIFY -- perform all possible substitutions, then stringify */
  37. #define    __STR(x)    #x        /* just a helper macro */
  38. #define    STRINGIFY(x)    __STR(x)
  39.  
  40.  
  41. #endif    _NRW_REG_HELP_H_
  42.