Added the Global Descriptor Table.
This commit is contained in:
+20
-1
@@ -16,6 +16,25 @@ global inb
|
||||
; 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.
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user