-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathio.s
More file actions
25 lines (21 loc) · 711 Bytes
/
Copy pathio.s
File metadata and controls
25 lines (21 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
global inb
global outb
global load_idt
section .text
; Read byte from I/O port: inb(port)
inb:
mov dx, [esp + 4] ; Get port number from stack argument
in al, dx ; Read byte into AL register
ret ; Return value in AL
; Write byte to I/O port: outb(port, value)
outb:
mov dx, [esp + 4] ; Get port number
mov al, [esp + 8] ; Get value to write
out dx, al ; Send byte to hardware port
ret
; Load Interrupt Descriptor Table pointer: load_idt(idtp_address)
load_idt:
mov edx, [esp + 4] ; Get address of IDT pointer
lidt [edx] ; Execute x86 LIDT instruction
sti ; Enable hardware interrupts
ret