Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. case 0x24: //SUB A-B - Regsiter subtracted to Accumulator with Carry - completed during week 1
  2.  
  3. //Subtracts registers to accumulator
  4. temp_word = (WORD)Registers[REGISTER_A] - (WORD)Registers[REGISTER_B];
  5. if ((Flags & FLAG_C) != 0)
  6. {
  7. temp_word--;
  8. }
  9.  
  10. if (temp_word >= 0x100)
  11. {
  12. Flags = Flags | FLAG_C; // set carry flag
  13. }
  14. else
  15. {
  16. Flags = Flags & (0xff - FLAG_C); //Clear carry flag
  17. }
  18. //Sets flags
  19. set_flag_n(temp_word);
  20. set_flag_z(temp_word);
  21. set_flag_v(Registers[REGISTER_A], -Registers[REGISTER_B], temp_word);
  22. //Stores into accumulator
  23. Registers[REGISTER_A] = temp_word;
  24.  
  25.  
  26. break;
  27.  
  28. case 0x34: //SUB A-C - Regsiter subtracted to Accumulator with Carry - completed during week 1
  29.  
  30. //Subtracts registers to accumulator
  31. temp_word = (WORD)Registers[REGISTER_A] - (WORD)Registers[REGISTER_C];
  32. if ((Flags & FLAG_C) != 0)
  33. {
  34. temp_word--;
  35. }
  36.  
  37. if (temp_word >= 0x100)
  38. {
  39. Flags = Flags | FLAG_C; // set carry flag
  40. }
  41. else
  42. {
  43. Flags = Flags & (0xff - FLAG_C); //Clear carry flag
  44. }
  45. //Sets flags
  46. set_flag_n(temp_word);
  47. set_flag_z(temp_word);
  48. set_flag_v(Registers[REGISTER_A], -Registers[REGISTER_C], temp_word);
  49. //Stores into accumulator
  50. Registers[REGISTER_A] = temp_word;
  51. break;
  52.  
  53. case 0x44: //SUB A-D - Regsiter subtracted to Accumulator with Carry - completed during week 1
  54.  
  55. //Subtracts registers to accumulator
  56. temp_word = (WORD)Registers[REGISTER_A] - (WORD)Registers[REGISTER_D];
  57. if ((Flags & FLAG_C) != 0)
  58. {
  59. temp_word--;
  60. }
  61.  
  62. if (temp_word >= 0x100)
  63. {
  64. Flags = Flags | FLAG_C; // set carry flag
  65. }
  66. else
  67. {
  68. Flags = Flags & (0xff - FLAG_C); //Clear carry flag
  69. }
  70. //Sets flags
  71. set_flag_n(temp_word);
  72. set_flag_z(temp_word);
  73. set_flag_v(Registers[REGISTER_A], -Registers[REGISTER_D], temp_word);
  74. //Stores into accumulator
  75. Registers[REGISTER_A] = temp_word;
  76.  
  77. break;
  78.  
  79. case 0x54: //SUB A-E - Regsiter subtracted to Accumulator with Carry - completed during week 1
  80.  
  81. //Subtracts registers to accumulator
  82. temp_word = (WORD)Registers[REGISTER_A] - (WORD)Registers[REGISTER_E];
  83. if ((Flags & FLAG_C) != 0)
  84. {
  85. temp_word--;
  86. }
  87.  
  88. if (temp_word >= 0x100)
  89. {
  90. Flags = Flags | FLAG_C; // set carry flag
  91. }
  92. else
  93. {
  94. Flags = Flags & (0xff - FLAG_C); //Clear carry flag
  95. }
  96. //Sets flags
  97. set_flag_n(temp_word);
  98. set_flag_z(temp_word);
  99. set_flag_v(Registers[REGISTER_A], -Registers[REGISTER_E], temp_word);
  100. //Stores into accumulator
  101. Registers[REGISTER_A] = temp_word;
  102.  
  103. break;
  104.  
  105. case 0x64: //SUB A-F - Regsiter subtracted to Accumulator with Carry - completed during week 1
  106.  
  107. //Subtracts registers to accumulator
  108. temp_word = (WORD)Registers[REGISTER_A] - (WORD)Registers[REGISTER_F];
  109. if ((Flags & FLAG_C) != 0)
  110. {
  111. temp_word--;
  112. }
  113.  
  114. if (temp_word >= 0x100)
  115. {
  116. Flags = Flags | FLAG_C; // set carry flag
  117. }
  118. else
  119. {
  120. Flags = Flags & (0xff - FLAG_C); //Clear carry flag
  121. }
  122. //Sets flags
  123. set_flag_n(temp_word);
  124. set_flag_z(temp_word);
  125. set_flag_v(Registers[REGISTER_A], -Registers[REGISTER_F], temp_word);
  126. //Stores into accumulator
  127. Registers[REGISTER_A] = temp_word;
  128.  
  129. break;
  130. ///////////END SUB///////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement