66 write(address, operand);
76 uint16_t result =
A + value +
PSW.
C;
77 PSW.
V = ((
A ^ result) & (value ^ result) & 0x80) != 0;
78 PSW.
H = ((
A & 0xf) + (value & 0xf) +
PSW.
C) > 0xf;
79 PSW.
C = (result > 0xFF);
82 PSW.
N = (
A & 0x80) != 0;
87 uint8_t applyOn =
read(dest);
88 int result = applyOn + operand +
PSW.
C;
89 PSW.
V = ((applyOn & 0x80) == (operand & 0x80)) &&
90 ((operand & 0x80) != (result & 0x80));
91 PSW.
H = ((applyOn & 0xf) + (operand & 0xf) +
PSW.
C) > 0xf;
92 PSW.
C = result > 0xff;
93 write(dest, result & 0xFF);
94 PSW.
Z = ((result & 0xFF) == 0);
95 PSW.
N = (result & 0x80) != 0;
100 uint8_t value =
read(
adr) ^ 0xff;
101 int result =
A + value +
PSW.
C;
102 PSW.
V = ((
A & 0x80) == (value & 0x80)) &&
103 ((value & 0x80) != (result & 0x80));
104 PSW.
H = ((
A & 0xf) + (value & 0xf) +
PSW.
C) > 0xf;
105 PSW.
C = result > 0xff;
108 PSW.
N = (
A & 0x80) != 0;
114 uint8_t applyOn =
read(dest);
115 int result = applyOn + operand +
PSW.
C;
116 PSW.
V = ((applyOn & 0x80) == (operand & 0x80)) &&
117 ((operand & 0x80) != (result & 0x80));
118 PSW.
H = ((applyOn & 0xF) + (operand & 0xF) +
PSW.
C) > 0xF;
119 PSW.
C = result > 0xFF;
120 write(dest, result & 0xFF);
121 PSW.
Z = ((result & 0xFF) == 0);
122 PSW.
N = (result & 0x80) != 0;
131 uint8_t value =
read(
adr) ^ 0xff;
132 int result =
A + value + 1;
133 PSW.
C = result > 0xff;
134 PSW.
Z = ((result & 0xFF) == 0);
135 PSW.
N = (result & 0x80) != 0;
140 uint8_t value =
read(
adr) ^ 0xff;
141 int result =
X + value + 1;
142 PSW.
C = result > 0xff;
143 PSW.
Z = ((result & 0xFF) == 0);
144 PSW.
N = (result & 0x80) != 0;
149 uint8_t value =
read(
adr) ^ 0xff;
150 int result =
Y + value + 1;
151 PSW.
C = result > 0xff;
152 PSW.
Z = ((result & 0xFF) == 0);
153 PSW.
N = (result & 0x80) != 0;
159 int result =
read(dst) + value + 1;
160 PSW.
C = result > 0xff;
162 PSW.
Z = ((result & 0xFF) == 0);
163 PSW.
N = (result & 0x80) != 0;
174 PSW.
N = (
A & 0x80) != 0;
179 uint8_t result =
read(dest) & operand;
181 PSW.
Z = (result == 0);
182 PSW.
N = (result & 0x80) != 0;
189 PSW.
N = (
A & 0x80) != 0;
194 uint8_t result =
read(dst) | value;
196 PSW.
Z = (result == 0);
197 PSW.
N = (result & 0x80) != 0;
204 PSW.
N = (
A & 0x80) != 0;
209 uint8_t result =
read(dest) ^ operand;
211 PSW.
Z = (result == 0);
212 PSW.
N = (result & 0x80) != 0;
223 PSW.
C = (val & 0x80) != 0;
227 PSW.
N = (val & 0x80) != 0;
234 PSW.
C = (val & 0x01) != 0;
238 PSW.
N = (val & 0x80) != 0;
245 bool newC = (val & 0x80) != 0;
246 val = (val << 1) |
PSW.
C;
250 PSW.
N = (val & 0x80) != 0;
257 bool newC = (val & 1) != 0;
258 val = (val >> 1) | (
PSW.
C << 7);
262 PSW.
N = (val & 0x80) != 0;
276 PSW.
N = (val & 0x80) != 0;
286 PSW.
N = (val & 0x80) != 0;
291 uint8_t value = isImmediate ?
imm() : operand;
292 value = ((value & 0xF0) >> 4) | ((value & 0x0F) << 4);
293 PSW.
Z = (value == 0);
294 PSW.
N = (value & 0x80) != 0;
304 PSW.
Z = (operand == 0);
305 PSW.
N = (operand & 0x8000) != 0;
311 PSW.
Z = (operand == 0);
312 PSW.
N = (operand & 0x8000) != 0;
318 PSW.
Z = (operand == 0);
319 PSW.
N = (operand & 0x8000) != 0;
324 uint32_t result = dest + operand;
325 PSW.
C = (result > 0xFFFF);
326 PSW.
Z = ((result & 0xFFFF) == 0);
327 PSW.
N = (result & 0x8000) != 0;
328 PSW.
V = ((dest ^ result) & (operand ^ result) & 0x8000) != 0;
329 PSW.
H = ((dest & 0xfff) + (operand & 0xfff)) > 0xfff;
330 dest = result & 0xFFFF;
335 uint32_t result = dest - operand;
336 PSW.
C = (result <= 0xFFFF);
337 PSW.
Z = ((result & 0xFFFF) == 0);
338 PSW.
N = (result & 0x8000) != 0;
339 PSW.
V = ((dest ^ result) & (dest ^ operand) & 0x8000) != 0;
340 PSW.
H = ((dest & 0xfff) - (operand & 0xfff)) >= 0;
341 dest = result & 0xFFFF;
346 uint32_t result =
YA - operand;
347 PSW.
C = (result <= 0xFFFF);
348 PSW.
Z = ((result & 0xFFFF) == 0);
349 PSW.
N = (result & 0x8000) != 0;
358 uint16_t result =
A * operand;
360 PSW.
Z = (result == 0);
361 PSW.
N = (result & 0x8000) != 0;
372 uint8_t quotient =
A / operand;
373 uint8_t remainder =
A % operand;
376 PSW.
Z = (quotient == 0);
377 PSW.
N = (quotient & 0x80) != 0;
397 if (operand & (1 << bit))
PC +=
rel();
401 if (!(operand & (1 << bit)))
PC +=
rel();
413 uint16_t return_address =
PC + 2;
420 uint16_t return_address =
PC + 2;
427 uint16_t return_address =
PC + 2;
430 PC = 0xFFDE + offset;
467 operand |= (1 << bit);
471 operand &= ~(1 << bit);
475 PSW.
C = (operand & (1 << bit)) != 0;
476 operand |= (1 << bit);
480 PSW.
C = (operand & (1 << bit)) != 0;
481 operand &= ~(1 << bit);
485 operand &= (1 << bit);
486 PSW.
Z = (operand == 0);
487 PSW.
N = (operand & 0x80) != 0;
491 operand |= (1 << bit);
492 PSW.
Z = (operand == 0);
493 PSW.
N = (operand & 0x80) != 0;
497 operand ^= (1 << bit);
498 PSW.
Z = (operand == 0);
499 PSW.
N = (operand & 0x80) != 0;
503 operand ^= (1 << bit);
504 PSW.
Z = (operand == 0);
505 PSW.
N = (operand & 0x80) != 0;
509 PSW.
C = (operand & (1 << bit)) != 0;
510 operand |= (1 << bit);
void CMPM(uint16_t dst, uint8_t value)
void SUBW(uint16_t &dest, uint16_t operand)
void PCALL(uint8_t offset)
void JMP(uint16_t address)
uint8_t read(uint16_t address)
void NOT1(uint8_t bit, uint8_t &operand)
void AND1(uint8_t bit, uint8_t &operand)
void ANDM(uint16_t dest, uint8_t operand)
void MOVW(uint16_t &dest, uint16_t operand)
void EORM(uint16_t dest, uint8_t operand)
void DEC(uint16_t operand)
void DIV(uint8_t operand)
void EOR1(uint8_t bit, uint8_t &operand)
void SBCM(uint16_t &dest, uint8_t operand)
void SET1(uint8_t bit, uint8_t &operand)
void push_byte(uint8_t value)
void TCLR1(uint8_t bit, uint8_t &operand)
uint8_t FlagsToByte(Flags flags)
void TCALL(uint8_t offset)
void ROL(uint16_t operand)
void MOV_ADDR(uint16_t address, uint8_t operand)
void write(uint16_t address, uint8_t value)
void XCN(uint8_t operand, bool isImmediate=false)
void PUSH(uint8_t operand)
void ADDW(uint16_t &dest, uint16_t operand)
void INCW(uint16_t &operand)
void BBC(uint8_t bit, uint8_t operand)
void CALL(uint16_t address)
void DECW(uint16_t &operand)
void push_word(uint16_t value)
void BBS(uint8_t bit, uint8_t operand)
uint16_t read_word(uint16_t address)
void POP(uint8_t &operand)
void ASL(uint16_t operand)
void CLR1(uint8_t bit, uint8_t &operand)
void ADCM(uint16_t &dest, uint8_t operand)
void OR1(uint8_t bit, uint8_t &operand)
void CMPW(uint16_t operand)
void MOV1(uint8_t bit, uint8_t &operand)
void TSET1(uint8_t bit, uint8_t &operand)
void ORM(uint16_t dest, uint8_t operand)
Flags ByteToFlags(uint8_t byte)
void MUL(uint8_t operand)
Main namespace for the application.
std::function< void(bool)> idle