computer beeps when key pressed

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
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

computer beeps when key pressed

Post by kubeos »

Hello,

Newbie question. I am working on the keyboard driver and when I hit a key, it reads the scancode and returns what I want by reading from port 0x60. But on a real machine everytime i hit a key I get a beep from the speaker as well. Am I supposed to send something back to the keyboard to clear the buffer or something?

Thanks in advance.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

If you are running in real mode, the bios might still be hooked up to the keyboard interrupt, which beeps when it gets many keypresses without calls to read the buffer. You will need to unhook the bios from IRQ1 to fix this (as well as any other problems it might be causing)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

Also have you sent a

Code: Select all

	mov   al,0x20
	out   0x20,al		                        ; quiet screaming irq chip.
After you read you should send the above, if your key function is called on IRQ.
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

stupid djgpp (or stupid me...)

Post by kubeos »

Well, i was trying to code it in djgpp... I really just don't understand c that well I guess. I rewrote the routines in my own compiler and everything works perfect. No beeping or anything. So I'm gonna do the whole kernel in a c-- language.
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Post by bubach »

that should be intresting.. do you have any webpage or blog or anything where people could read about your progress? someone might find a c-- resource useful.
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

hmmm..

Post by kubeos »

I have a page for kube at http://www.bc5.ca

But thats the old 16-bit version. As for the compiler, it's actually pretty awefull. It doesn't pass pointers to strings, it actually copies the string from its location to a global variable, then in the called function, it copies it from the global var into the functions var... the only reason I'm using it for my kernel is because it uses nasm as its assembler. So if anyone REALLY wants to program in c-- they should check out sphinx c--, its much better.

Anyway, once I've got a few things fixed with my 32-bit version of Kube, I'll post it on the site, and probably post the 32-bit version of my compiler as well, just in case anyone wants to see how terrible of a programmer I really am.
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

So if anyone REALLY wants to program in c-- they should check out sphinx c--, its much better
ehh.. try gcc it is even better... at least if you are not doing real mode.
Author of COBOS
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

os64dev wrote:
So if anyone REALLY wants to program in c-- they should check out sphinx c--, its much better
ehh.. try gcc it is even better... at least if you are not doing real mode.
os64dev, sphinx c-- is technically a different language.. Although it's just a strange hybrid language between ASM and C..

http://www.goosee.com/cmm/cpuspeed.c-- (Example of the syntax..)

http://www.goosee.com/cmm/

http://c--sphinx.narod.ru/indexe.htm

It's worth the effort just to learn Assembly/C and use GCC though..
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
kubeos
Member
Member
Posts: 138
Joined: Tue Jan 30, 2007 2:31 pm
Location: Kamloops BC, CANADA
Contact:

getting off topic...

Post by kubeos »

Well... I would prefer to use gcc anyway... So let me ask this.

How does gcc pass a string pointer?

eg..
extern int function(const char *something);
x=function("hello world");

in my asm function

global _function
_function:
push ebp
mov ebp,esp
sub esp,0x40
mov ebx,[ebp+8]
[CONFUSED ABOUT EBX???]
....more code
leave
ret

So what does ebx contain? Is it a pointer to the "hello world" string which I can use with edi or esi.. or is it something else.. If I can figure out the strings then I can probably continue with gcc.

Sorry, maybe I should have asked this in a new thread..

EDIT: forgot the extern on the function declaration.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Code: Select all

somewhere:
push string ; pushes pointer to string: string on stack
call function ; pushes eip on the stack: eip-string on stack

function:
push ebp ; pushed ebp: ebp-eip-string on stack
mov ebp, esp ;ebp points to ebp-eip-string
; ebp+4 points to eip
; ebp+8 points to string
mov ebx, [ebp+8] ; ebx points to null terminated string
...
mov al, [ebx] ; al is the first character in the string
inc ebx
mov al, [ebx] ; al is the second character in the string
...
leave ; restores esp and pops ebp
ret ; restores eip
I think this should do...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply