Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm new to OS-development and I finally write my own PMODE OS. It's very basic with some 80*25 video functions.
I got some questions about the A20 gate:
enable_A20:
[BITS 16]
cli ;; Interrupts uit
call a20wait
mov al, 0xAD ;; Disable keyboard
out 0x64, al
call a20wait
mov al, 0xD0 ;; Read
out 0x64, al
call a20wait2
in al, 0x60 ;; lees status in al
push eax ;; Push naar de stack, bij de volgende call gaat het verloren
call a20wait
mov al,0xD1 ;; Write
out 0x64, al
call a20wait
pop eax ;; status weer van de stack halen
or al, 2 ;; Check of A20 gate aanspreekbaar is
out 0x60, al ;; nieuwe waarde in het keyboard status register plaatsen
call a20wait
mov al, 0xAE
out 0x64, al ;; enable keyboard
call a20wait
sti ;; enable interrupts
ret
a20wait:
.10: mov ecx, 65536 ;; kleine delay
.11: in al, 0x64
test al, 2 ;; testen op bit 2, kijk of de output buffer leeg is
jz .12
loop .11
jmp .10
.12: ret
a20wait2:
.10: mov ecx, 65536 ;; kleine delay
.11: in al, 0x64
test al, 1 ;; testen op bit 1, kijk of de keyboard-controller klaar is
jnz .12
loop .11
jmp .10
.12: ret
My question is why does the A20 gate is ORed. I don't get the point why you need to OR to get the A20 bit.
Hey,
the bit that enables the a20 is stored in the 'output port' of the keyboard controller. The asm code you posted (basically) works as following:
1) Read the value from the (keyboard controller's) output-port in
2) Set the a20 bit
3) Write the (modified) value back to the output-port
I hope you do know how an OR operation works in general ?
An OR-disjunction is always true if (at least!) one of the two operands is true. Don't get mixed up because in everyday language "or" is mostly used to express "either a or b". In logic this would be called "exclusive or" (XOR).
Z = X OR Y
X = 0101b
Y = 1001b
--------------
Z = 1101
Just compare X and Y bit by bit:
X = 0___b
Y = 1___b
Z = 1___b
X = _1__b
Y = _0__b
Z = 11__b
...
From the code snippet:
(al = out-port = ??????0?)
or al, 10b
(al = ??????1? - a20 bit set)