aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/registers.h
blob: d2f2e74ece5b221e9235a95bbdab3870069c8ba4 (plain)
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
#pragma once

#include <types.h>

namespace x86 {

struct cpu_state {
  /* registers stored by pusha */
  // indexes and pointers
  uint32_t edi;  // destination index: string, memory copying and setting, far pointer addressing with ES
  uint32_t esi;  // source index: string and memory copying
  uint32_t ebp;  // stack base pointer
  const uint32_t esp;  // stack pointer; this register is not used by popa

  // general registers
  uint32_t ebx;  // base register: base pointer for memory access
  uint32_t edx;  // data register: I/O ports, arithmetic
  uint32_t ecx;  // counter register: loop counter, for shifts
  uint32_t eax;  // accumulator register: I/O ports, arithmetic

  /* pushed by interrupt handler macros */
  uint32_t irq;    // interrupt number
  uint32_t error;  // error code

  /* stack frame, pushed by cpu */
  uint32_t eip;
  uint32_t cs;
  uint32_t eflags;
  uint32_t __esp;
  uint32_t ss;
} __attribute__((packed));

}  // namespace x86

typedef x86::cpu_state cpu_state_t;