3void add(uint8_t d, uint8_t r,
struct CORE *core) {
8 uint8_t R_tmp = core->
gp.
R[d];
11 core->
gp.
R[d] = core->
gp.
R[d] + core->
gp.
R[r];
19void adc(uint8_t d, uint8_t r,
struct CORE *core) {
24 uint8_t R_tmp = core->
gp.
R[d];
35void adiw(uint8_t d, uint8_t K,
struct CORE *core) {
41 uint16_t Rd = core->
gp.
R[d] | (core->
gp.
R[d + 1] << 8);
42 uint16_t result = Rd + K;
43 core->
gp.
R[d] = result & 0xFF;
44 core->
gp.
R[d + 1] = (result >> 8) & 0xFF;
52void sub(uint8_t d, uint8_t r,
struct CORE *core) {
57 uint8_t R_tmp = core->
gp.
R[d];
60 core->
gp.
R[d] = core->
gp.
R[d] - core->
gp.
R[r];
68void subi(uint8_t d, uint8_t K,
struct CORE *core) {
73 uint8_t R_tmp = core->
gp.
R[d];
76 core->
gp.
R[d] = core->
gp.
R[d] - K;
84void sbc(uint8_t d, uint8_t r,
struct CORE *core) {
89 uint8_t R_tmp = core->
gp.
R[d];
100void sbci(uint8_t d, uint8_t K,
struct CORE *core) {
105 uint8_t R_tmp = core->
gp.
R[d];
116void sbiw(uint8_t d, uint8_t K,
struct CORE *core) {
122 uint16_t Rd = core->
gp.
R[d] | (core->
gp.
R[d + 1] << 8);
123 uint16_t result = Rd - K;
124 core->
gp.
R[d] = result & 0xFF;
125 core->
gp.
R[d + 1] = (result >> 8) & 0xFF;
133void and(uint8_t d, uint8_t r,
struct CORE *core) {
139 core->
gp.
R[d] = core->
gp.
R[d] & core->
gp.
R[r];
147void andi(uint8_t d, uint8_t K,
struct CORE *core) {
153 core->
gp.
R[d] = core->
gp.
R[d] & K;
161void or(uint8_t d, uint8_t r,
struct CORE *core) {
167 core->
gp.
R[d] = core->
gp.
R[d] | core->
gp.
R[r];
175void ori(uint8_t d, uint8_t K,
struct CORE *core) {
181 core->
gp.
R[d] = core->
gp.
R[d] | K;
189void eor(uint8_t d, uint8_t r,
struct CORE *core) {
195 core->
gp.
R[d] = core->
gp.
R[d] ^ core->
gp.
R[r];
209 core->
gp.
R[d] = ~core->gp.R[d];
224 core->
gp.
R[d] = -core->
gp.
R[d];
228void sbr(uint8_t d, uint8_t K,
struct CORE *core) {
234 core->
gp.
R[d] = core->
gp.
R[d] | K;
238void cbr(uint8_t d, uint8_t K,
struct CORE *core) {
244 core->
gp.
R[d] = core->
gp.
R[d] & ~K;
254 core->
gp.
R[d] = core->
gp.
R[d] + 1;
264 core->
gp.
R[d] = core->
gp.
R[d] - 1;
274 core->
gp.
R[d] = core->
gp.
R[d] & core->
gp.
R[d];
294 core->
gp.
R[d] = 0xFF;
298void mul(uint8_t d, uint8_t r,
struct CORE *core) {
304 uint16_t result = (uint16_t)core->
gp.
R[d] * (uint16_t)core->
gp.
R[r];
305 core->
gp.
R[0] = result & 0xFF;
306 core->
gp.
R[1] = (result >> 8) & 0xFF;
310void muls(uint8_t d, uint8_t r,
struct CORE *core) {
316 int16_t result = (int16_t)core->
gp.
R[d] * (int16_t)core->
gp.
R[r];
317 core->
gp.
R[0] = result & 0xFF;
318 core->
gp.
R[1] = (result >> 8) & 0xFF;
328 int16_t result = (int16_t)core->
gp.
R[d] * (uint16_t)core->
gp.
R[r];
329 core->
gp.
R[0] = result & 0xFF;
330 core->
gp.
R[1] = (result >> 8) & 0xFF;
334void fmul(uint8_t d, uint8_t r,
struct CORE *core) {
340 uint16_t result = (uint16_t)core->
gp.
R[d] * (uint16_t)(core->
gp.
R[r] << 1);
341 core->
gp.
R[0] = result & 0xFF;
342 core->
gp.
R[1] = (result >> 8) & 0xFF;
352 int16_t result = (int16_t)core->
gp.
R[d] * (int16_t)(core->
gp.
R[r] << 1);
353 core->
gp.
R[0] = result & 0xFF;
354 core->
gp.
R[1] = (result >> 8) & 0xFF;
364 int16_t result = (int16_t)core->
gp.
R[d] * (uint16_t)(core->
gp.
R[r] << 1);
365 core->
gp.
R[0] = result & 0xFF;
366 core->
gp.
R[1] = (result >> 8) & 0xFF;
void mul(uint8_t d, uint8_t r, struct CORE *core)
Multiplies two unsigned 8-bit integers and stores the result in the CORE structure.
void adc(uint8_t d, uint8_t r, struct CORE *core)
Add with carry.
void subi(uint8_t d, uint8_t K, struct CORE *core)
Subtract immediate.
void sub(uint8_t d, uint8_t r, struct CORE *core)
Subtract.
void tst(uint8_t d, struct CORE *core)
Test for zero or minus after AND operation.
void inc(uint8_t d, struct CORE *core)
Increment the value of a register.
void add(uint8_t d, uint8_t r, struct CORE *core)
Add without carry.
void ser(uint8_t d, struct CORE *core)
Set all bits in a register.
void fmul(uint8_t d, uint8_t r, struct CORE *core)
Multiplies two unsigned 8-bit integers with fractional representation and stores the result in the CO...
void dec(uint8_t d, struct CORE *core)
Decrement the value of a register.
void muls(uint8_t d, uint8_t r, struct CORE *core)
Multiplies two signed 8-bit integers and stores the result in the CORE structure.
void andi(uint8_t d, uint8_t K, struct CORE *core)
Logical AND with immediate.
void eor(uint8_t d, uint8_t r, struct CORE *core)
Perform bitwise exclusive OR between two registers.
void sbr(uint8_t d, uint8_t K, struct CORE *core)
Set bits in a register.
void clr(uint8_t d, struct CORE *core)
Clear a register (set to zero).
void ori(uint8_t d, uint8_t K, struct CORE *core)
Logical OR with immediate.
void sbci(uint8_t d, uint8_t K, struct CORE *core)
Subtract immediate with carry.
void mulsu(uint8_t d, uint8_t r, struct CORE *core)
Multiplies a signed 8-bit integer with an unsigned 8-bit integer and stores the result in the CORE st...
void fmulsu(uint8_t d, uint8_t r, struct CORE *core)
Multiplies a signed 8-bit integer with an unsigned 8-bit integer with fractional representation and s...
void or(uint8_t d, uint8_t r, struct CORE *core)
Logical OR.
void cbr(uint8_t d, uint8_t K, struct CORE *core)
Clear bits in a register.
void com(uint8_t d, struct CORE *core)
Perform one's complement on a register.
void fmuls(uint8_t d, uint8_t r, struct CORE *core)
Multiplies two signed 8-bit integers with fractional representation and stores the result in the CORE...
void and(uint8_t d, uint8_t r, struct CORE *core)
Logical AND.
void neg(uint8_t d, struct CORE *core)
Perform two's complement (negation) on a register.
void adiw(uint8_t d, uint8_t K, struct CORE *core)
Add immediate to word.
void sbc(uint8_t d, uint8_t r, struct CORE *core)
Subtract with carry.
void sbiw(uint8_t d, uint8_t K, struct CORE *core)
Subtract immediate from word.
Arithmetic and logic operations.
void inc_pc(struct CORE *core)
void update_sreg_arithm(struct CORE *core, uint8_t Rd, uint8_t Rr, uint8_t result)
Updates the Status Register (SREG) for arithmetic operations.
void update_sreg_logic(struct CORE *core, uint8_t result)
Updates the Status Register (SREG) for logical operations.
void udpate_sreg_arithm_16bit(struct CORE *core, uint16_t Rd, uint16_t result)
Updates the Status Register (SREG) for 16-bit arithmetic operations.
void update_sreg_C(struct CORE *core, bool state)
Update the Carry flag (C) in the status register.
Core structure containing general purpose registers, program counter, stack pointer,...