~vdupras/collapseos

ref: 421ca5112f091f8ba3322a13e128e083e6bd1615 collapseos/emul/8086/cpu.h -rwxr-xr-x 1.2 KiB
421ca511Virgil Dupras Remove one level of C< override 1 year, 10 months ago
                                                                                
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
#pragma once
#define regax 0
#define regcx 1
#define regdx 2
#define regbx 3
#define regsp 4
#define regbp 5
#define regsi 6
#define regdi 7
#define reges 0
#define regcs 1
#define regss 2
#define regds 3

#ifdef __BIG_ENDIAN__
#define regal 1
#define regah 0
#define regcl 3
#define regch 2
#define regdl 5
#define regdh 4
#define regbl 7
#define regbh 6
#else
#define regal 0
#define regah 1
#define regcl 2
#define regch 3
#define regdl 4
#define regdh 5
#define regbl 6
#define regbh 7
#endif

#define segbase(x)	((uint32_t) x << 4)
#define getmem8(x, y)	read86(segbase(x) + y)
#define getmem16(x, y)	readw86(segbase(x) + y)
#define putmem8(x, y, z)	write86(segbase(x) + y, z)
#define putmem16(x, y, z)	writew86(segbase(x) + y, z)
#define getreg16(regid)	regs.wordregs[regid]
#define putreg16(regid, writeval)	regs.wordregs[regid] = writeval

typedef void (*INTHOOK) ();
union _bytewordregs_ {
	uint16_t wordregs[8];
	uint8_t byteregs[8];
};


void write86 (uint32_t addr32, uint8_t value);
void writew86 (uint32_t addr32, uint16_t value);
uint8_t read86 (uint32_t addr32);
uint16_t readw86 (uint32_t addr32);
int exec86(int execloops); // returns 0 if halted
void reset86(uint16_t startip);