Questions about OS [NEWBIE]

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.
Post Reply
Petertje
Posts: 7
Joined: Wed Apr 13, 2005 11:00 pm

Questions about OS [NEWBIE]

Post by Petertje »

Hi,

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:

Code: Select all

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.

Thanks, Peter
Petertje
Posts: 7
Joined: Wed Apr 13, 2005 11:00 pm

Re: Questions about OS [NEWBIE]

Post by Petertje »

Does nobody know why?
why does it is ORed the A20 gatebit is 02, but why is it ORed???
please, :)
User avatar
gaf
Member
Member
Posts: 349
Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany

Re: Questions about OS [NEWBIE]

Post by gaf »

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

You can find a definition of the output-port's fields aswell as a listing of the various keyboard controller commands on this site (http://www.computer-engineering.org/ps2keyboard/).

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)

Have a look at en.wikipedia.org/wiki/Logical_disjunction for some more details..

regards,
gaf
[AlAdDiN]
Member
Member
Posts: 108
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re: Questions about OS [NEWBIE]

Post by [AlAdDiN] »

Petertje wrote: 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.
Do you have a simpler solution ;) ??
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
Petertje
Posts: 7
Joined: Wed Apr 13, 2005 11:00 pm

Re: Questions about OS [NEWBIE]

Post by Petertje »

Thanks alot!
I do now understand :)
Petertje
Posts: 7
Joined: Wed Apr 13, 2005 11:00 pm

Re: Questions about OS [NEWBIE]

Post by Petertje »

And it is not 64 decimal because its in big endian, right?

2 = 00000010
64=01000000
Petertje
Posts: 7
Joined: Wed Apr 13, 2005 11:00 pm

Re: Questions about OS [NEWBIE]

Post by Petertje »

I no, I was a little confused. 00000010 the 1 is bit 2.

Thanks :D,

Peter
Post Reply