accumulatore.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "elea_tipi.h"
  2. #include "governo.h"
  3. #include "memoria.h"
  4. static carattere Accumulatore[100];
  5. static segno REG_SEGNO_A = 0;
  6. int op_da(istruzione *i)
  7. {
  8. int r;
  9. int da;
  10. r = estrai_cifra(i->da.I[0]);
  11. if (r < 0)
  12. return -1;
  13. da = r;
  14. r = estrai_cifra(i->da.I[1]);
  15. if (r < 0)
  16. return -1;
  17. da += 10 * r;
  18. R.P = da;
  19. return 0;
  20. }
  21. int op_fam(istruzione *i)
  22. {
  23. return 0;
  24. }
  25. int op_aom(istruzione *i)
  26. {
  27. int pos;
  28. indirizzo mem;
  29. int lun;
  30. int j;
  31. mem = estrai_indirizzo(i->gen.I);
  32. if (mem == (uint32_t)(-1))
  33. return -1;
  34. lun = estrai_lunghezza(i->gen.L);
  35. for (j = 0; j < lun; j++) {
  36. pos = (R.P + lun - (j + 1));
  37. mem_scrivi_carattere(mem + j, Accumulatore[pos] & 0x7F);
  38. /* Azzeramento */
  39. Accumulatore[pos] = 0x80;
  40. }
  41. return 0;
  42. }
  43. int op_piu_ma(istruzione *i)
  44. {
  45. return 0;
  46. }
  47. int op_cma(istruzione *i)
  48. {
  49. return 0;
  50. }
  51. /* Da memoria a accumulatore */
  52. int op_ma(istruzione *i)
  53. {
  54. int j;
  55. int pos;
  56. int lun;
  57. int r;
  58. indirizzo mem;
  59. mem = estrai_indirizzo(i->gen.I);
  60. if (mem == (uint32_t)(-1))
  61. return -1;
  62. lun = estrai_lunghezza(i->gen.L);
  63. if (lun < 0)
  64. return -1;
  65. for (j = 0; j < lun; j++) {
  66. carattere c;
  67. pos = (lun - (j + 1));
  68. c = mem_leggi_carattere(mem);
  69. Accumulatore[R.P + j] = c & 0x7f;
  70. Accumulatore[R.P + j] &= ~0x80;
  71. }
  72. /* accende gA nell'ultimo carattere */
  73. Accumulatore[R.P + lun - j] |= 0x80;
  74. return 0;
  75. }
  76. int op_am(istruzione *i)
  77. {
  78. return 0;
  79. }
  80. int op_piu_am(istruzione *i)
  81. {
  82. return 0;
  83. }
  84. int op_meno_ma(istruzione *i)
  85. {
  86. return 0;
  87. }