arm_dyncom_run.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Copyright (C)
  2. * 2011 - Michael.Kang blackfin.kang@gmail.com
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU General Public License
  5. * as published by the Free Software Foundation; either version 2
  6. * of the License, or (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  16. *
  17. */
  18. #pragma once
  19. #include "core/arm/skyeye_common/armstate.h"
  20. /**
  21. * Checks if the PC is being read, and if so, word-aligns it.
  22. * Used with address calculations.
  23. *
  24. * @param cpu The ARM CPU state instance.
  25. * @param Rn The register being read.
  26. *
  27. * @return If the PC is being read, then the word-aligned PC value is returned.
  28. * If the PC is not being read, then the value stored in the register is returned.
  29. */
  30. static inline u32 CHECK_READ_REG15_WA(ARMul_State* cpu, int Rn) {
  31. return (Rn == 15) ? ((cpu->Reg[15] & ~0x3) + cpu->GetInstructionSize() * 2) : cpu->Reg[Rn];
  32. }
  33. /**
  34. * Reads the PC. Used for data processing operations that use the PC.
  35. *
  36. * @param cpu The ARM CPU state instance.
  37. * @param Rn The register being read.
  38. *
  39. * @return If the PC is being read, then the incremented PC value is returned.
  40. * If the PC is not being read, then the values stored in the register is returned.
  41. */
  42. static inline u32 CHECK_READ_REG15(ARMul_State* cpu, int Rn) {
  43. return (Rn == 15) ? ((cpu->Reg[15] & ~0x1) + cpu->GetInstructionSize() * 2) : cpu->Reg[Rn];
  44. }