1 :(before "End Initialize Op Names(name)")
2 put(name, "cd", "software interrupt");
3
4 :(before "End Single-Byte Opcodes")
5 case 0xcd: {
6 trace(90, "run") << "syscall" << end();
7 uint8_t code = next();
8 if (code != 0x80) {
9 raise << "Unimplemented interrupt code " << HEXBYTE << code << '\n' << end();
10 raise << " Only `int 80h` supported for now.\n" << end();
11 break;
12 }
13 process_int80();
14 break;
15 }
16
17 :(code)
18 void process_int80() {
19 switch (Reg[EAX].u) {
20 case 1:
21 exit(Reg[EBX].u);
22 break;
23 case 3:
24 Reg[EAX].i = read(Reg[EBX].u, mem_addr_u8(Reg[ECX].u), Reg[EDX].u);
25 break;
26 case 4:
27 Reg[EAX].i = write(Reg[EBX].u, mem_addr_u8(Reg[ECX].u), Reg[EDX].u);
28 break;
29 default:
30 raise << HEXWORD << EIP << ": unimplemented syscall " << Reg[EAX].u << '\n' << end();
31 }
32 }