<commit_before>bits 32

global loadGDT
global loadIDT

section .text

;;; void loadGDT(gdt::GdtPtr*)
loadGDT:
    push  eax
    mov   eax, [esp+0x8]
    lgdt  [eax]
    pop   eax
    ;; Reload CS register containing code selector.
    ;; We can't directly alter CS, so we far jump to change it
    jmp   0x08:.reload_CS ; 0x08 points at the new code selector (2nd in our GDT)
.reload_CS:
    ;; Reload data segment registers.
    mov   ax, 0x10 ; 0x10 points at the new data selector (3rd in our GDT)
    mov   ds, ax
    mov   es, ax
    mov   fs, ax
    mov   gs, ax
    mov   ss, ax
    ret

;;; void loadIDT(idt::IdtPtr*)
loadIDT:
    push  eax
    mov   eax, [esp+0x8]
    lidt  [eax]
    pop   eax
    ret

;;;
;;; Exceptions, ISRs, IRQs, Syscalls
;;;

extern isrHandler
extern irqHandler

global isrSyscall

isrSyscall:
    cli
    push  0
    push  0x80
    jmp   isrCommon
    iret

%macro HANDLER_COMMON 1
%1Common:
    pusha
    push  ds
    push  es
    push  fs
    push  gs
    mov   ax, 0x10
    mov   ds, ax
    mov   es, ax
    mov   fs, ax
    mov   gs, ax
    mov   eax, esp
    push  eax
    ;mov   eax, %1Handler
    ;call  eax
    call %1Handler
    pop   eax
    pop   gs
    pop   fs
    pop   es
    pop   ds
    popa
    add   esp, 4
    iret
%endmacro

HANDLER_COMMON isr
HANDLER_COMMON irq

;; WRAPPER (isr|irq), n, intnum
;;   Makes a wrapper for interrupt 'intnum' called isrn or irqn. The wrapper
;;   jumps to isrHandler or irqHandler.
%macro WRAPPER 3
global %1%2
%1%2:
    cli
    push  %3 ; Interrupt number
    jmp   %1Common
%endmacro

;; Wrappers for ISRs 0 through 31 on interrupts 0 to 31.
%assign i 0
%rep 32
    WRAPPER isr, i, i
    %assign i i+1
%endrep

;; Wrappers for IRQs 0 through 15 on interrupts 32 through 47.
%assign i 0
%rep 16
    %assign k i+32
    WRAPPER irq, i, k
    %assign i i+1
%endrep
<commit_msg>Remove unused code<commit_after>bits 32

global loadGDT
global loadIDT

section .text

;;; void loadGDT(gdt::GdtPtr*)
loadGDT:
    push  eax
    mov   eax, [esp+0x8]
    lgdt  [eax]
    pop   eax
    ;; Reload CS register containing code selector.
    ;; We can't directly alter CS, so we far jump to change it
    jmp   0x08:.reload_CS ; 0x08 points at the new code selector (2nd in our GDT)
.reload_CS:
    ;; Reload data segment registers.
    mov   ax, 0x10 ; 0x10 points at the new data selector (3rd in our GDT)
    mov   ds, ax
    mov   es, ax
    mov   fs, ax
    mov   gs, ax
    mov   ss, ax
    ret

;;; void loadIDT(idt::IdtPtr*)
loadIDT:
    push  eax
    mov   eax, [esp+0x8]
    lidt  [eax]
    pop   eax
    ret

;;;
;;; Exceptions, ISRs, IRQs, Syscalls
;;;

extern isrHandler
extern irqHandler

global isrSyscall

isrSyscall:
    cli
    push  0
    push  0x80
    jmp   isrCommon
    iret

%macro HANDLER_COMMON 1
%1Common:
    pusha
    push  ds
    push  es
    push  fs
    push  gs
    mov   ax, 0x10
    mov   ds, ax
    mov   es, ax
    mov   fs, ax
    mov   gs, ax
    mov   eax, esp
    push  eax
    call %1Handler
    pop   eax
    pop   gs
    pop   fs
    pop   es
    pop   ds
    popa
    add   esp, 4
    iret
%endmacro

HANDLER_COMMON isr
HANDLER_COMMON irq

;; WRAPPER (isr|irq), n, intnum
;;   Makes a wrapper for interrupt 'intnum' called isrn or irqn. The wrapper
;;   jumps to isrHandler or irqHandler.
%macro WRAPPER 3
global %1%2
%1%2:
    cli
    push  %3 ; Interrupt number
    jmp   %1Common
%endmacro

;; Wrappers for ISRs 0 through 31 on interrupts 0 to 31.
%assign i 0
%rep 32
    WRAPPER isr, i, i
    %assign i i+1
%endrep

;; Wrappers for IRQs 0 through 15 on interrupts 32 through 47.
%assign i 0
%rep 16
    %assign k i+32
    WRAPPER irq, i, k
    %assign i i+1
%endrep

{'fraction_non_alphanumeric': 0.0727075420510038, 'fraction_numerical': 0.03336950623982637, 'mean_word_length': 2.132540356839422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5234164', 'n_tokens_mistral': 1571, 'n_tokens_neox': 1430, 'n_words': 525}