libmicroemu 0.2.0
ARM Microcontroller Emulator Library
Loading...
Searching...
No Matches
unary_instr_imm_carry.h
1#pragma once
2#include "libmicroemu/internal/decoder/decoder.h"
3
4#include "libmicroemu/internal/executor/instr_context.h"
5#include "libmicroemu/internal/executor/instr_exec_results.h"
7#include "libmicroemu/internal/utils/rarg.h"
8#include "libmicroemu/register_details.h"
9#include "libmicroemu/types.h"
10
11namespace libmicroemu::internal {
12
18template <typename TInstrContext> class MovImmCarryOp {
19public:
20 template <typename TDest>
21 static Result<InstrExecFlagsSet> Call(TInstrContext &ictx, const InstrFlagsSet &iflags,
22 const TDest &rd, const ThumbImmediateResult &imm_carry) {
23 auto apsr = ictx.cpua.template ReadSpecialRegister<SpecialRegisterId::kApsr>();
24 const auto op_res = OpResult{imm_carry.out, imm_carry.carry_out,
25 (apsr & ApsrRegister::kVMsk) == ApsrRegister::kVMsk};
26
27 PostExecWriteRegPcExcluded::Call(ictx, rd, op_res.value);
28
29 PostExecOptionalSetFlags::Call(ictx, iflags, op_res);
30 PostExecAdvancePcAndIt::Call(ictx, iflags);
31 return Ok(kNoInstrExecFlags);
32 }
33};
34
40template <typename TInstrContext> class MvnImmCarryOp {
41public:
42 template <typename TDest>
43 static Result<InstrExecFlagsSet> Call(TInstrContext &ictx, const InstrFlagsSet &iflags,
44 const TDest &rd, const ThumbImmediateResult &imm_carry) {
45 auto apsr = ictx.cpua.template ReadSpecialRegister<SpecialRegisterId::kApsr>();
46 const auto op_res = OpResult{~imm_carry.out, imm_carry.carry_out,
47 (apsr & ApsrRegister::kVMsk) == ApsrRegister::kVMsk};
48
49 PostExecWriteRegPcExcluded::Call(ictx, rd, op_res.value);
50 PostExecOptionalSetFlags::Call(ictx, iflags, op_res);
51 PostExecAdvancePcAndIt::Call(ictx, iflags);
52 return Ok(kNoInstrExecFlags);
53 }
54};
55
56template <typename TOp, typename TInstrContext> class UnaryInstrImmCarry {
57public:
58 using It = typename TInstrContext::It;
59 using Pc = typename TInstrContext::Pc;
60
61 template <typename TDest>
62 static Result<InstrExecResult> Call(TInstrContext &ictx, const InstrFlagsSet &iflags,
63 const TDest &rd, const ThumbImmediateResult &imm_carry) {
64 TRY_ASSIGN(condition_passed, InstrExecResult, It::ConditionPassed(ictx.cpua));
65 if (!condition_passed) {
66 PostExecAdvancePcAndIt::Call(ictx, iflags);
67 return Ok(InstrExecResult{kNoInstrExecFlags});
68 }
69
70 TRY_ASSIGN(eflags, InstrExecResult, TOp::Call(ictx, iflags, rd, imm_carry));
71 return Ok(InstrExecResult{eflags});
72 }
73
74private:
78 UnaryInstrImmCarry() = delete;
79
83 ~UnaryInstrImmCarry() = delete;
84
89 UnaryInstrImmCarry(const UnaryInstrImmCarry &r_src) = delete;
90
95 UnaryInstrImmCarry &operator=(const UnaryInstrImmCarry &r_src) = delete;
96
101 UnaryInstrImmCarry(UnaryInstrImmCarry &&r_src) = delete;
102
107 UnaryInstrImmCarry &operator=(UnaryInstrImmCarry &&r_src) = delete;
108};
109
110} // namespace libmicroemu::internal
Mov.
Definition unary_instr_imm_carry.h:18
Mvn.
Definition unary_instr_imm_carry.h:40
The libmicroemu::internal namespace contains all classes and functions of libmicroemu which are priva...
Definition bkpt_flags.h:6
Contains the Result class which is used to return the result of a function.
#define TRY_ASSIGN(NAME, OUT_TYPE, CALL)
Try to assign a value to a variable and return an error if the assignment fails.
Definition result.h:123
Definition thumb_immediate_result.h:6
Definition instr_exec_results.h:23
Definition post_exec.h:12
Definition result.h:15