diff options
author | Tom Stellard <tstellar@gmail.com> | 2010-12-28 16:59:01 -0800 |
---|---|---|
committer | Tom Stellard <tstellar@gmail.com> | 2010-12-28 16:59:01 -0800 |
commit | 4850bd80e72383d7a860e3e2ec54a68e1b35ae72 (patch) | |
tree | 9a068387923c74b5a52efe4adca6f6f80d362037 | |
parent | 5c1a650314816b0517ce4a76eec75349c44cb956 (diff) |
instruction: Add MOV instruction
-rw-r--r-- | instruction.cpp | 14 | ||||
-rw-r--r-- | instruction.h | 6 |
2 files changed, 20 insertions, 0 deletions
diff --git a/instruction.cpp b/instruction.cpp index 2b67c8e..8509eb6 100644 --- a/instruction.cpp +++ b/instruction.cpp @@ -48,3 +48,17 @@ add_instruction::execute(emulator & emulator) emulator.set_value(m_dst[i], val); } } + +mov_instruction::mov_instruction(std::vector<register_address> dst) : + instruction("MOV", NULL, dst, 1) + { } + +void +mov_instruction::execute(emulator & emulator) +{ + unsigned int i; + for (i = 0; i < m_dst.size(); i++) { + emulator.set_value(m_dst[i], + emulator.get_value(m_src_regs[0][i])); + } +} diff --git a/instruction.h b/instruction.h index f17530a..8e3a201 100644 --- a/instruction.h +++ b/instruction.h @@ -42,4 +42,10 @@ private: std::vector<register_address> m_src1; }; +class mov_instruction : public instruction { +public: + mov_instruction(std::vector<register_address> dst); + void execute(emulator & emulator); +}; + #endif //INSTRUCTION_H_ |