home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / Geneve / 9640news / CAT36 / EMULSRC.ZIP / OPERANDS.C < prev    next >
Text File  |  1993-04-27  |  2KB  |  105 lines

  1. /* This part provides the operands for the different types of opcodes.
  2.    The operand values are returned via globals defined in TI99EMUL.H
  3. */
  4.  
  5.  
  6. #define BYTE_OPERATION IR&0x1000
  7.  
  8. void typeIoperands(void)
  9. {
  10.     get_source_operand();
  11.     get_dest_operand();
  12.     if (!(BYTE_OPERATION))
  13.         { SourceOpAdr&=0xFFFE; DestOpAdr&=0xFFFE; }
  14.     SourceVal=memory_read(SourceOpAdr);
  15.         DestVal=memory_read(DestOpAdr);
  16. }
  17.  
  18. void typeIIIoperands(void)
  19. {
  20.     get_source_operand();
  21.     SourceVal=memory_read(SourceOpAdr&0xFFFE);
  22.     DestOpAdr=WP+((IR>>5)&0x1e);
  23.     DestVal=memory_read(DestOpAdr);
  24. }
  25.  
  26. void typeIVoperands(void)
  27. {
  28.     get_source_operand();
  29.     SourceVal=memory_read(SourceOpAdr&=0xFFFE);
  30.     DestVal=(IR>>6)&0xF;
  31. }
  32.  
  33. void typeVoperands(void)
  34. {
  35.     SourceOpAdr=WP+((IR&0xF)<<1);
  36.     SourceVal=memory_read(SourceOpAdr);
  37.     DestVal=(IR>>4)&0xF;
  38.     if (!DestVal)
  39.     {
  40.         DestVal=memory_read(WP)&0xF;
  41.         if (!DestVal) DestVal=16;
  42.     }
  43. }
  44.  
  45. void typeVIoperands(void)
  46. {
  47.     get_source_operand();
  48.     SourceVal=memory_read(SourceOpAdr&=0xFFFE);
  49. }
  50.  
  51. void typeVIIIoperands(void)
  52. {
  53.     SourceOpAdr=WP+((IR&0xF)<<1);
  54.     SourceVal=memory_read(SourceOpAdr);
  55.     DestVal=memory_read(PC);
  56.     PC+=2;
  57. }
  58.  
  59. void typeIXoperands(void)
  60. {
  61.     SourceOpAdr=WP+((IR&0xF)<<1);
  62. }
  63.  
  64. void typeXoperands(void)
  65. {
  66.     SourceVal=memory_read(PC);
  67.     PC+=2;
  68. }
  69.  
  70. void get_source_operand(void)
  71. {
  72.     switch((IR>>4)&3)
  73.     {
  74.     case 0:     SourceOpAdr=WP+((IR&0xF)<<1); /* Register direct */
  75.             break;
  76.     case 1:     SourceOpAdr=memory_read(WP+((IR&0xF)<<1));
  77.             break;
  78.     case 2:     SourceOpAdr=memory_read(PC); PC+=2;
  79.             if (IR&0xF) SourceOpAdr+=memory_read(WP+((IR&0xF)<<1));
  80.             break;
  81.     case 3:        SourceOpAdr=memory_read(WP+((IR&0xF)<<1));
  82.             memory_write(WP+((IR&0xF)<<1),SourceOpAdr+
  83.             ((BYTE_OPERATION) ? 1:2));
  84.             break;
  85.     }
  86. }
  87.  
  88. void get_dest_operand(void)
  89. {
  90.     switch((IR>>10)&3)
  91.     {
  92.     case 0:     DestOpAdr=WP+((IR>>5)&0x1E); /* Register direct */
  93.             break;
  94.     case 1:     DestOpAdr=memory_read(WP+((IR>>5)&0x1E));
  95.             break;
  96.     case 2:     DestOpAdr=memory_read(PC); PC+=2;
  97.             if (IR&0x3c0) DestOpAdr+=memory_read(WP+((IR>>5)&0x1E));
  98.             break;
  99.     case 3:     DestOpAdr=memory_read(WP+((IR>>5)&0x1E));
  100.             memory_write(WP+((IR>>5)&0x1E),
  101.             DestOpAdr+((BYTE_OPERATION) ? 1:2));
  102.             break;
  103.     }
  104. }
  105.