home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / trash / part02 / i_b.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-22  |  4.9 KB  |  336 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_bc1f(dipc, offset)
  9. dinstrn    *dipc;
  10. short    offset;
  11. {
  12.     unsigned long    c;
  13.  
  14.     procsget(CP1CS, c);
  15.  
  16.     if (Test_Cond(c) == 0)
  17.         dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
  18.  
  19.     return dipc;
  20. }
  21.  
  22. dinstrn    *
  23. i_bc1t(dipc, offset)
  24. dinstrn    *dipc;
  25. short    offset;
  26. {
  27.     unsigned long    c;
  28.  
  29.     procsget(CP1CS, c);
  30.  
  31.     if (Test_Cond(c) == 1)
  32.         dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
  33.  
  34.     return dipc;
  35. }
  36.  
  37. static
  38. dinstrn    *
  39. c_beq0(dipc)
  40. dinstrn    *dipc;
  41. {
  42.     if (*dipc->di_0 == 0)
  43.         do_known_delayed_branch;
  44.  
  45.     return dipc;
  46. }
  47.  
  48. static
  49. dinstrn    *
  50. c_beq0_up(dipc)
  51. dinstrn    *dipc;
  52. {
  53.     if (*dipc->di_0 == 0)
  54.         do_known_delayed_upbranch;
  55.  
  56.     return dipc;
  57. }
  58.  
  59. static
  60. dinstrn    *
  61. c_beq(dipc)
  62. dinstrn    *dipc;
  63. {
  64.     if (*dipc->di_0 == *dipc->di_1)
  65.         do_known_delayed_branch;
  66.  
  67.     return dipc;
  68. }
  69.  
  70. static
  71. dinstrn    *
  72. c_beq_up(dipc)
  73. dinstrn    *dipc;
  74. {
  75.     if (*dipc->di_0 == *dipc->di_1)
  76.         do_known_delayed_upbranch;
  77.  
  78.     return dipc;
  79. }
  80.  
  81. dinstrn    *
  82. i_beq(dipc, rs, rt, offset)
  83. dinstrn    *dipc;
  84. int    rs;
  85. int    rt;
  86. short    offset;
  87. {
  88.     unsigned long    s;
  89.     unsigned long    t;
  90.     unsigned long    target;
  91.  
  92.     target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
  93.  
  94.     if (compile_ok)
  95.     {
  96.         if (rt == R_0)
  97.             dipc->di_handler = (target > dipc->di_addr) ? c_beq0 : c_beq0_up;
  98.         else
  99.             dipc->di_handler = (target > dipc->di_addr) ? c_beq : c_beq_up;
  100.  
  101.         dipc->di_0 = &P.p_state[rs];
  102.         dipc->di_1 = &P.p_state[rt];
  103.  
  104.         (void)compile_known_delayed_branch(dipc, target);
  105.  
  106.         return (*dipc->di_handler)(dipc);
  107.     }
  108.  
  109.     procsget(rs, s);
  110.  
  111.     procsget(rt, t);
  112.  
  113.     if (s == t)
  114.         dipc = do_delayed_branch(dipc, target);
  115.  
  116.     return dipc;
  117. }
  118.  
  119. static
  120. dinstrn    *
  121. c_bgez(dipc)
  122. dinstrn    *dipc;
  123. {
  124.     if ((long)*dipc->di_0 >= 0)
  125.         do_known_delayed_branch;
  126.  
  127.     return dipc;
  128. }
  129.  
  130. static
  131. dinstrn    *
  132. c_bgez_up(dipc)
  133. dinstrn    *dipc;
  134. {
  135.     if ((long)*dipc->di_0 >= 0)
  136.         do_known_delayed_upbranch;
  137.  
  138.     return dipc;
  139. }
  140.  
  141. dinstrn    *
  142. i_bgez(dipc, rs, rt, offset)
  143. dinstrn    *dipc;
  144. int    rs;
  145. int    rt;
  146. short    offset;
  147. {
  148.     unsigned long    target;
  149.     long        s;
  150.  
  151.     target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
  152.  
  153.     if (compile_ok)
  154.     {
  155.         dipc->di_handler = c_bgez;
  156.         dipc->di_handler = (target > dipc->di_addr) ? c_bgez : c_bgez_up;
  157.         dipc->di_0 = &P.p_state[rs];
  158.         (void)compile_known_delayed_branch(dipc, target);
  159.  
  160.         return (*dipc->di_handler)(dipc);
  161.     }
  162.  
  163.     procsget(rs, *(unsigned long *)&s);
  164.  
  165.     if (s >= 0)
  166.         dipc = do_delayed_branch(dipc, target);
  167.  
  168.     return dipc;
  169. }
  170.  
  171. static
  172. dinstrn    *
  173. c_bgtz(dipc)
  174. dinstrn    *dipc;
  175. {
  176.     if ((long)*dipc->di_0 > 0)
  177.         do_known_delayed_branch;
  178.  
  179.     return dipc;
  180. }
  181.  
  182. static
  183. dinstrn    *
  184. c_bgtz_up(dipc)
  185. dinstrn    *dipc;
  186. {
  187.     if ((long)*dipc->di_0 > 0)
  188.         do_known_delayed_upbranch;
  189.  
  190.     return dipc;
  191. }
  192.  
  193. dinstrn    *
  194. i_bgtz(dipc, rs, rt, offset)
  195. dinstrn    *dipc;
  196. int    rs;
  197. int    rt;
  198. short    offset;
  199. {
  200.     unsigned long    target;
  201.     long        s;
  202.  
  203.     target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
  204.  
  205.     if (compile_ok)
  206.     {
  207.         dipc->di_handler = (target > dipc->di_addr) ? c_bgtz : c_bgtz_up;
  208.         dipc->di_0 = &P.p_state[rs];
  209.         (void)compile_known_delayed_branch(dipc, target);
  210.  
  211.         return (*dipc->di_handler)(dipc);
  212.     }
  213.  
  214.     procsget(rs, *(unsigned long *)&s);
  215.  
  216.     if (s > 0)
  217.         dipc = do_delayed_branch(dipc, target);
  218.  
  219.     return dipc;
  220. }
  221.  
  222. dinstrn    *
  223. i_blez(dipc, rs, rt, offset)
  224. dinstrn    *dipc;
  225. int    rs;
  226. int    rt;
  227. short    offset;
  228. {
  229.     long    s;
  230.  
  231.     procsget(rs, *(unsigned long *)&s);
  232.  
  233.     if (s <= 0)
  234.         dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
  235.  
  236.     return dipc;
  237. }
  238.  
  239. dinstrn    *
  240. i_bltz(dipc, rs, rt, offset)
  241. dinstrn    *dipc;
  242. int    rs;
  243. int    rt;
  244. short    offset;
  245. {
  246.     long    s;
  247.  
  248.     procsget(rs, *(unsigned long *)&s);
  249.  
  250.     if (s < 0)
  251.         dipc = do_delayed_branch(dipc, (unsigned long)(dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2)));
  252.  
  253.     return dipc;
  254. }
  255.  
  256. static
  257. dinstrn    *
  258. c_bne0(dipc)
  259. dinstrn    *dipc;
  260. {
  261.     if (*dipc->di_0 != 0)
  262.         do_known_delayed_branch;
  263.  
  264.     return dipc;
  265. }
  266.  
  267. static
  268. dinstrn    *
  269. c_bne0_up(dipc)
  270. dinstrn    *dipc;
  271. {
  272.     if (*dipc->di_0 != 0)
  273.         do_known_delayed_upbranch;
  274.  
  275.     return dipc;
  276. }
  277.  
  278. static
  279. dinstrn    *
  280. c_bne(dipc)
  281. dinstrn    *dipc;
  282. {
  283.     if (*dipc->di_0 != *dipc->di_1)
  284.         do_known_delayed_branch;
  285.  
  286.     return dipc;
  287. }
  288.  
  289. static
  290. dinstrn    *
  291. c_bne_up(dipc)
  292. dinstrn    *dipc;
  293. {
  294.     if (*dipc->di_0 != *dipc->di_1)
  295.         do_known_delayed_upbranch;
  296.  
  297.     return dipc;
  298. }
  299.  
  300. dinstrn    *
  301. i_bne(dipc, rs, rt, offset)
  302. dinstrn    *dipc;
  303. int    rs;
  304. int    rt;
  305. short    offset;
  306. {
  307.     unsigned long    target;
  308.     unsigned long    s;
  309.     unsigned long    t;
  310.  
  311.     target = dipc->di_addr + sizeof(unsigned long) + (((long)offset) << 2);
  312.  
  313.     if (compile_ok)
  314.     {
  315.         if (rt == R_0)
  316.             dipc->di_handler = (target > dipc->di_addr) ? c_bne0 : c_bne0_up;
  317.         else
  318.             dipc->di_handler = (target > dipc->di_addr) ? c_bne : c_bne_up;
  319.  
  320.         dipc->di_0 = &P.p_state[rs];
  321.         dipc->di_1 = &P.p_state[rt];
  322.         (void)compile_known_delayed_branch(dipc, target);
  323.  
  324.         return (*dipc->di_handler)(dipc);
  325.     }
  326.  
  327.     procsget(rs, s);
  328.  
  329.     procsget(rt, t);
  330.  
  331.     if (s != t)
  332.         dipc = do_delayed_branch(dipc, target);
  333.  
  334.     return dipc;
  335. }
  336.