Files

51 lines
1.2 KiB
ArmAsm

global outb
; outb - Send a byte to an I/O port.
; stack: [esp + 8] The data byte
; [esp + 4] The I/O port
; [esp ] Return address
outb:
mov al, [esp + 8] ; Move the data to send into the AL register
mov dx, [esp + 4] ; Move the address of the I/O port into the DX register
out dx, al ; Send the data to the I/O port
ret ; Return
global inb
; inb - Returns a byte from the give I/O port.
; stack: [esp + 4] The address of the I/O port
; [esp ] The return address
inb:
mov dx, [esp + 4] ; Move the address of the I/O port to the dx register
in al, dx ; Read a byte from the I/O port and store it in the al register
ret
global load_gdt
; load_gdt - Installs a new GDT
; stack: [esp + 4] The address of the GDT
; [esp ] The return addess
load_gdt:
mov eax, [esp + 4]
lgdt [eax]
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:return ; Perform a "far jump" to load 0x08 in the CS register
return:
ret ; Now we've changed CS to 0x08
global load_idt
; load_idt - Installs the IDT
; stack: [esp + 4] The address of the IDT
; [esp ] The return address
load_idt:
mov eax, [esp + 4]
lidt [eax]
ret