libmicroemu 0.2.0
ARM Microcontroller Emulator Library
Loading...
Searching...
No Matches
binary_null_instr_with_imm_carry.h
1#pragma once
2#include "libmicroemu/internal/decoder/decoder.h"
3#include "libmicroemu/internal/executor/instr/post_exec.h"
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 Tst1ImmCarryOp {
19public:
20 template <typename TArg0>
21 static Result<InstrExecFlagsSet> Call(TInstrContext &ictx, const InstrFlagsSet &iflags,
22 const TArg0 &rn, const ThumbImmediateResult &imm_carry) {
23 const auto n = ictx.cpua.ReadRegister(rn.Get());
24 auto apsr = ictx.cpua.template ReadSpecialRegister<SpecialRegisterId::kApsr>();
25 const auto result = Alu32::AND(n, imm_carry.out);
26
27 const auto op_res =
28 OpResult{result, imm_carry.carry_out, (apsr & ApsrRegister::kVMsk) == ApsrRegister::kVMsk};
29
30 PostExecSetFlags::Call(ictx, op_res);
31 PostExecAdvancePcAndIt::Call(ictx, iflags);
32 return Ok(kNoInstrExecFlags);
33 }
34};
35
41template <typename TInstrContext> class Teq1ImmCarryOp {
42public:
43 template <typename TArg0>
44 static Result<InstrExecFlagsSet> Call(TInstrContext &ictx, const InstrFlagsSet &iflags,
45 const TArg0 &rn, const ThumbImmediateResult &imm_carry) {
46 const auto n = ictx.cpua.ReadRegister(rn.Get());
47 auto apsr = ictx.cpua.template ReadSpecialRegister<SpecialRegisterId::kApsr>();
48 const auto result = Alu32::EOR(n, imm_carry.out);
49
50 const auto op_res =
51 OpResult{result, imm_carry.carry_out, (apsr & ApsrRegister::kVMsk) == ApsrRegister::kVMsk};
52
53 PostExecSetFlags::Call(ictx, op_res);
54 PostExecAdvancePcAndIt::Call(ictx, iflags);
55 return Ok(kNoInstrExecFlags);
56 }
57};
58
59template <typename TOp, typename TInstrContext> class BinaryNullInstrWithImmCarry {
60public:
61 using It = typename TInstrContext::It;
62 using Pc = typename TInstrContext::Pc;
63
64 template <typename TArg0>
65 static Result<InstrExecResult> Call(TInstrContext &ictx, const InstrFlagsSet &iflags,
66 const TArg0 &rn, const ThumbImmediateResult &imm_carry) {
67 TRY_ASSIGN(condition_passed, InstrExecResult, It::ConditionPassed(ictx.cpua));
68 if (!condition_passed) {
69 PostExecAdvancePcAndIt::Call(ictx, iflags);
70 return Ok(InstrExecResult{kNoInstrExecFlags});
71 }
72
73 TRY_ASSIGN(eflags, InstrExecResult, TOp::Call(ictx, iflags, rn, imm_carry));
74 return Ok(InstrExecResult{eflags});
75 }
76
77private:
81 BinaryNullInstrWithImmCarry() = delete;
82
86 ~BinaryNullInstrWithImmCarry() = delete;
87
92 BinaryNullInstrWithImmCarry(const BinaryNullInstrWithImmCarry &r_src) = delete;
93
98 BinaryNullInstrWithImmCarry &operator=(const BinaryNullInstrWithImmCarry &r_src) = delete;
99
104 BinaryNullInstrWithImmCarry(BinaryNullInstrWithImmCarry &&r_src) = delete;
105
110 BinaryNullInstrWithImmCarry &operator=(BinaryNullInstrWithImmCarry &&r_src) = delete;
111};
112
113} // namespace libmicroemu::internal
Teq.
Definition binary_null_instr_with_imm_carry.h:41
Tst.
Definition binary_null_instr_with_imm_carry.h:18
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