#include "arch/kernel/cpu/tr.hpp" namespace teachos::arch::kernel::cpu { auto store_task_register() -> uint16_t { uint16_t current_value{}; asm("str %[output]" : [output] "=r"(current_value)); return current_value; } auto load_task_register(uint16_t gdt_offset) -> void { // asm volatile("ltr %[input]" : /* no output from call */ : [input] "R"(gdt_offset)); // https://www.scs.stanford.edu/05au-cs240c/lab/i386/s07_03.htm asm volatile("mov %[input], %%ax\n" "ltr %%ax\n" : /* no output from call */ : [input] "r"(gdt_offset) : "ax"); } } // namespace teachos::arch::kernel::cpu