home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / assembler / as / src / c / help_cpu < prev    next >
Encoding:
Text File  |  1992-07-20  |  590 b   |  26 lines

  1.  
  2. /*
  3.  * help_cpu.c
  4.  * Copyright © 1992 Niklas Röjemo
  5.  */
  6.  
  7. #include "help_cpu.h"
  8. #include "error.h"
  9.  
  10. static int mask[] = {
  11.   0x000000ff, 0xc000003f, 0xf000000f, 0xfc000003,
  12.   0xff000000, 0x3fc00000, 0x0ff00000, 0x03fc0000,
  13.   0x00ff0000, 0x003fc000, 0x000ff000, 0x0003fc00,
  14.   0x0000ff00, 0x00003fc0, 0x00000ff0, 0x000003fc
  15.   };
  16.  
  17. int help_cpuImm8s4(int value)
  18. {                            
  19.   int i;
  20.   for(i=0; i<16; i++) {
  21.     if((value & mask[i]) == value)      /* hittat mask */
  22.       return(((((unsigned int)value >> ((16 - i) * 2)) | value << (i * 2)) & 0xff) | i << 8);
  23.   }
  24.   return -1;
  25. }
  26.