computer beeps when key pressed
computer beeps when key pressed
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.
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.
Also have you sent a
After you read you should send the above, if your key function is called on IRQ.
Code: Select all
mov al,0x20
out 0x20,al ; quiet screaming irq chip.
stupid djgpp (or stupid me...)
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.
hmmm..
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.
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.
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
os64dev, sphinx c-- is technically a different language.. Although it's just a strange hybrid language between ASM and C..os64dev wrote:ehh.. try gcc it is even better... at least if you are not doing real mode.So if anyone REALLY wants to program in c-- they should check out sphinx c--, its much better
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..
getting off topic...
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.
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.
- Combuster
- 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:
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