2 #include "Instruction.h"
9 Flash::Flash(unsigned int size
) : Memory(size
), decodedMem(size
/2) {
15 std::for_each( decodedMem
.begin(), decodedMem
.end(), Delete
<Instruction
>() );
18 static Instruction
*decodeOpcode(word opcode
) {
22 void Flash::write(unsigned int offset
, unsigned char *block
, unsigned int size
/*= 1*/) {
23 Memory::write(offset
, block
, size
);
27 void Flash::decode(unsigned int offset
, unsigned int size
) {
29 unsigned int addr
= offset
/ 2;
30 unsigned int count
= size
/ 2;
32 for(unsigned int i
= 0; i
< count
; ++i
) {
33 word opcode
= readWord(offset
);
35 opcode
= ((opcode
)>>8) | ((opcode
& 0xff)<<8);
38 if( decodedMem
[addr
] != 0 )
39 delete decodedMem
[addr
];
40 decodedMem
[addr
] = decodeOpcode(opcode
);