-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.h
75 lines (73 loc) · 992 Bytes
/
stack.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef stk
#define stk
#include "setup.h"
void CPU::push_b()
{
obj.mem[SP-1]=B;
obj.mem[SP-2]=C;
SP-=2;
}
void CPU::push_d()
{
obj.mem[SP-1]=D;
obj.mem[SP-2]=E;
SP-=2;
}
void CPU::push_h()
{
obj.mem[SP-1]=H;
obj.mem[SP-2]=L;
SP-=2;
}
void CPU::push_psw()
{
F |= (sign << 7);
F |= (zero << 6);
F |= (aux_carry << 4);
F |= (parity << 2);
F |= (carry << 0);
obj.mem[SP-1]=A;
obj.mem[SP-2]=F;
SP-=2;
}
void CPU::pop_b()
{
B=obj.mem[SP+1];
C=obj.mem[SP];
SP+=2;
}
void CPU::pop_d()
{
D=obj.mem[SP+1];
E=obj.mem[SP];
SP+=2;
}
void CPU::pop_h()
{
H=obj.mem[SP+1];
L=obj.mem[SP];
SP+=2;
}
void CPU::pop_psw()
{
A=obj.mem[SP+1];
F=obj.mem[SP];
SP+=2;
}
void CPU::xthl()
{
uint8_t x=H,y=L;
H=obj.mem[SP+1];
L=obj.mem[SP];
obj.mem[SP+1]=x;
obj.mem[SP]=y;
}
void CPU::pchl()
{
PC=((uint16_t)H<<8) | L;
}
void CPU::sphl()
{
SP=((uint16_t)H<<8) | L;
}
#endif