Commit | Line | Data |
---|---|---|
da32ed67 TG |
1 | #define c3(x) (0xff & (x>>24)) |
2 | #define c2(x) (0xff & (x>>16)) | |
3 | #define c1(x) (0xff & (x>> 8)) | |
4 | #define c0(x) (0xff & (x )) | |
546b5bab TG |
5 | #define LSL(x) carry = x>>7; x <<= 1; |
6 | #define LSR(x) carry = x&1; x >>= 1; | |
da32ed67 | 7 | #define SWAP(x) x = ((x & 0x0F) << 4 | (x & 0xF0) >> 4); |
da675ce7 | 8 | #define AND(x,y) x &= y; |
cb4533d4 | 9 | #define ANDI(x,n) x &= n; |
da675ce7 | 10 | #define OR(x,y) x |= y; |
cb4533d4 | 11 | #define ORI(x,n) x |= n; |
da675ce7 | 12 | #define EOR(x,y) x ^= y; |
546b5bab | 13 | #define ADD(x,y) carry = (x+y)>>8; x += y; |
f84bcb7f TG |
14 | #define ADC(x,y,c)x += y; x+=c; //TODO: carry |
15 | #define SUB(x,y) x -= y; //TODO: carry | |
16 | #define SUBI(x,n) x -= (u8)n; //TODO: carry | |
17 | #define INC(x) x++; //WARN: does not set carry | |
e2be3b5f | 18 | #define DEC(x) x--; sr_zero=!x; |
da32ed67 TG |
19 | #define MOV(x,y) x = y; |
20 | #define LDI(x,n) x = n; | |
7b96a97d TG |
21 | #define SBRC(x,b) if (x & 1<<b) //skip if cleared => do if set |
22 | #define SBRS(x,b) if (!(x & 1<<b)) //skip if set => do if not | |
da32ed67 TG |
23 | #define CLR(x) x = 0; |
24 | #define RET return; | |
25 | #define RCALL //pseudo | |
e5715654 TG |
26 | int sr_zero = 0; //status register zero bit |
27 | #define TST(x) if(x==0)sr_zero=1;else sr_zero=0; //WARN: not a complete TST mockup | |
28 | #define BREQ(l) if(sr_zero) goto l; | |
e2be3b5f | 29 | #define BRNE(l) if(!sr_zero) goto l; |
e4f7baf0 | 30 | int carry = 0; //status register carry bit //WARN: not respected by all mocked instructions |
df192822 TG |
31 | int asmtmp = 0; |
32 | #define ROL(x) asmtmp = x>>7; x <<= 1; x |= carry; carry = asmtmp; | |
33 | #define ROR(x) asmtmp = x&0x1; x >>= 1; x |= carry<<7; carry = asmtmp; | |
e4f7baf0 | 34 | #define NEG(x) x *= -1; |
c3639d5b | 35 | int sr_neg = 0; |
44e34da0 | 36 | #define CPI(x,n) sr_neg = (x-n < 0);sr_zero = (x-n == 0); //WARN: not a complete CPI mockup |
c3639d5b | 37 | #define BRPL(l) if (sr_neg) goto l; |
7b96a97d | 38 | #define RJMP(l) goto l; |