summaryrefslogtreecommitdiffhomepage
path: root/asm/intel64/int.cpp
blob: dbc6ae7cadb946e5757ae25294519c17d248a398 (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
#include "int.h"

#include <asm/assembler.h>

Op_int::Op_int(const Asm::Args& args)
{
 // At this point, the registration already ensured the number and types of args

 Asm::Args::Immediate8 i {std::any_cast<Asm::Args::Immediate8>(args[0])};

 if (i.value() == 0) { // INT 0
  machine_code = { 0xCE };
 } else if (i.value() == 1) { // INT 1
  machine_code = { 0xF1 };
 } else if (i.value() == 3) { // INT 3
  machine_code = { 0xCC };
 } else { // INT <...>
  machine_code = std::vector<uint8_t>{ 0xCD, i.value() };
 }
}

namespace {

bool registered { registerOp(mangleName<Asm::Args::Immediate8>("int"), [](const Asm::Args& args) -> std::shared_ptr<Op>{
                             return std::make_shared<Op_int>(args);
                             }) };

}