home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / trash / part01 / i_m.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-22  |  4.2 KB  |  325 lines

  1. #include    "register.h"
  2. #include    "symtab.h"
  3. #include    "diblock.h"
  4. #include    "instrn.h"
  5. #include    "process.h"
  6.  
  7. dinstrn    *
  8. i_mfc1(dipc, rt, fs)
  9. dinstrn    *dipc;
  10. int    rt;
  11. int    fs;
  12. {
  13.     unsigned long    t;
  14.  
  15.     procsget(CP1G(fs), t);
  16.  
  17.     procsput(rt, t);
  18.  
  19.     return dipc;
  20. }
  21.  
  22. static
  23. dinstrn    *
  24. c_mfhi(dipc)
  25. dinstrn    *dipc;
  26. {
  27.     *dipc->di_0 = P.p_state[R_HI];
  28.  
  29.     return dipc;
  30. }
  31.  
  32. dinstrn    *
  33. i_mfhi(dipc, rs, rt, rd, shamt, funct)
  34. dinstrn    *dipc;
  35. int    rs;
  36. int    rt;
  37. int    rd;
  38. int    shamt;
  39. int    funct;
  40. {
  41.     unsigned long    d;
  42.  
  43.     if (compile_ok)
  44.     {
  45.         if (rd == R_0)
  46.             dipc->di_handler = c_noop;
  47.         else
  48.         {
  49.             dipc->di_handler = c_mfhi;
  50.             dipc->di_0 = &P.p_state[rd];
  51.         }
  52.  
  53.         return (*dipc->di_handler)(dipc);
  54.     }
  55.  
  56.     procsget(R_HI, d);
  57.  
  58.     procsput(rd, d);
  59.  
  60.     return dipc;
  61. }
  62.  
  63. static
  64. dinstrn    *
  65. c_mflo(dipc)
  66. dinstrn    *dipc;
  67. {
  68.     *dipc->di_0 = P.p_state[R_LO];
  69.  
  70.     return dipc;
  71. }
  72.  
  73. dinstrn    *
  74. i_mflo(dipc, rs, rt, rd, shamt, funct)
  75. dinstrn    *dipc;
  76. int    rs;
  77. int    rt;
  78. int    rd;
  79. int    shamt;
  80. int    funct;
  81. {
  82.     unsigned long    d;
  83.  
  84.     if (compile_ok)
  85.     {
  86.         if (rd == R_0)
  87.             dipc->di_handler = c_noop;
  88.         else
  89.         {
  90.             dipc->di_handler = c_mflo;
  91.             dipc->di_0 = &P.p_state[rd];
  92.         }
  93.  
  94.         return (*dipc->di_handler)(dipc);
  95.     }
  96.  
  97.     procsget(R_LO, d);
  98.  
  99.     procsput(rd, d);
  100.  
  101.     return dipc;
  102. }
  103.  
  104. dinstrn    *
  105. i_movfmt(dipc, fmt, ft, fs, fd)
  106. dinstrn    *dipc;
  107. int    fmt;
  108. int    ft;
  109. int    fs;
  110. int    fd;
  111. {
  112.     float    singles;
  113.     double    doubles;
  114.  
  115.     switch (fmt)
  116.     {
  117.     case FMT_SINGLE:
  118.         procsget(CP1G(fs), *(unsigned long *)&singles);
  119.  
  120.         procsput(CP1G(fd), *(unsigned long *)&singles);
  121.  
  122.         break;
  123.  
  124.     case FMT_DOUBLE:
  125.         /*
  126.          * Note apparent reversal of words within
  127.          * doubles here -- no idea why.
  128.          */
  129.         procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  130.  
  131.         procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  132.  
  133.         procsput(CP1G(fd), *((unsigned long *)&doubles + 1));
  134.  
  135.         procsput(CP1G(fd) + 1, *(unsigned long *)&doubles);
  136.         break;
  137.  
  138.     default:
  139.         unrecognised(dipc);
  140.         break;
  141.     }
  142.  
  143.     return dipc;
  144. }
  145.  
  146. dinstrn    *
  147. i_mtc1(dipc, rt, fs)
  148. dinstrn    *dipc;
  149. int    rt;
  150. int    fs;
  151. {
  152.     unsigned long    t;
  153.  
  154.     procsget(rt, t);
  155.  
  156.     procsput(CP1G(fs), t);
  157.  
  158.     return dipc;
  159. }
  160.  
  161. dinstrn    *
  162. i_mthi(dipc, rs, rt, rd, shamt, funct)
  163. dinstrn    *dipc;
  164. int    rs;
  165. int    rt;
  166. int    rd;
  167. int    shamt;
  168. int    funct;
  169. {
  170.     unsigned long    v;
  171.  
  172.     procsget(rs, v);
  173.  
  174.     procsput(R_HI, v);
  175.  
  176.     return dipc;
  177. }
  178.  
  179. dinstrn    *
  180. i_mtlo(dipc, rs, rt, rd, shamt, funct)
  181. dinstrn    *dipc;
  182. int    rs;
  183. int    rt;
  184. int    rd;
  185. int    shamt;
  186. int    funct;
  187. {
  188.     unsigned long    v;
  189.  
  190.     procsget(rs, v);
  191.  
  192.     procsput(R_LO, v);
  193.  
  194.     return dipc;
  195. }
  196.  
  197. dinstrn    *
  198. i_mulfmt(dipc, fmt, ft, fs, fd)
  199. dinstrn    *dipc;
  200. int    fmt;
  201. int    ft;
  202. int    fs;
  203. int    fd;
  204. {
  205.     float    singles;
  206.     float    singlet;
  207.     float    singled;
  208.     double    doubles;
  209.     double    doublet;
  210.     double    doubled;
  211.  
  212.     switch (fmt)
  213.     {
  214.     case FMT_SINGLE:
  215.         procsget(CP1G(fs), *(unsigned long *)&singles);
  216.  
  217.         procsget(CP1G(ft), *(unsigned long *)&singlet);
  218.  
  219.         singled = singles * singlet;
  220.  
  221.         procsput(CP1G(fd), *(unsigned long *)&singled);
  222.  
  223.         break;
  224.  
  225.     case FMT_DOUBLE:
  226.         /*
  227.          * Note apparent reversal of words within
  228.          * doubles here -- no idea why.
  229.          */
  230.         procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  231.  
  232.         procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  233.  
  234.         procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  235.  
  236.         procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  237.  
  238.         doubled = doubles * doublet;
  239.  
  240.         procsput(CP1G(fd), *((unsigned long *)&doubled + 1));
  241.  
  242.         procsput(CP1G(fd) + 1, *(unsigned long *)&doubled);
  243.         break;
  244.  
  245.     default:
  246.         unrecognised(dipc);
  247.         break;
  248.     }
  249.  
  250.     return dipc;
  251. }
  252.  
  253. dinstrn    *
  254. i_mult(dipc, rs, rt, rd, shamt, funct)
  255. dinstrn    *dipc;
  256. int    rs;
  257. int    rt;
  258. int    rd;
  259. int    shamt;
  260. int    funct;
  261. {
  262.     unsigned long    s;
  263.     unsigned long    t;
  264.     unsigned long    hi;
  265.     unsigned long    lo;
  266.  
  267.     procsget(rs, s);
  268.  
  269.     procsget(rt, t);
  270.  
  271.     if (dmult(s, t, &hi, &lo) != -1)
  272.     {
  273.         procsput(R_HI, hi);
  274.         procsput(R_LO, lo);
  275.     }
  276.  
  277.     return dipc;
  278. }
  279.  
  280. static
  281. dinstrn    *
  282. c_multu(dipc)
  283. dinstrn    *dipc;
  284. {
  285.     (void)dmultu(*dipc->di_0, *dipc->di_1, &P.p_state[R_HI], &P.p_state[R_LO]);
  286.  
  287.     return dipc;
  288. }
  289.  
  290. dinstrn    *
  291. i_multu(dipc, rs, rt, rd, shamt, funct)
  292. dinstrn    *dipc;
  293. int    rs;
  294. int    rt;
  295. int    rd;
  296. int    shamt;
  297. int    funct;
  298. {
  299.     unsigned long    s;
  300.     unsigned long    t;
  301.     unsigned long    hi;
  302.     unsigned long    lo;
  303.  
  304.     if (compile_ok)
  305.     {
  306.         dipc->di_handler = c_multu;
  307.         dipc->di_0 = &P.p_state[rs];
  308.         dipc->di_1 = &P.p_state[rt];
  309.  
  310.         return (*dipc->di_handler)(dipc);
  311.     }
  312.  
  313.     procsget(rs, s);
  314.  
  315.     procsget(rt, t);
  316.  
  317.     if (dmultu(s, t, &hi, &lo) != -1)
  318.     {
  319.         procsput(R_HI, hi);
  320.         procsput(R_LO, lo);
  321.     }
  322.  
  323.     return dipc;
  324. }
  325.