user inputs

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
Mastermind

user inputs

Post by Mastermind »

How do you prompt for user inputs under C? I know you can't use any standard libs...
Mr_Spam

Re:user inputs

Post by Mr_Spam »

well, you have to display something, so you'll need video routines, and you'll need the keyboard, so you'll need interrupt vectors, maping the PIC, IRQ' routines, and your keyboard driver.
Whatever5k

Re:user inputs

Post by Whatever5k »

Standard Input requires a terminal driver - every character typed in is read by the keyboard driver and stored in a circular queue. When read()ing, the terminal driver gets the first character in the queue and returns it
Ozguxxx

Re:user inputs

Post by Ozguxxx »

you may also need a memory manager.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:user inputs

Post by Pype.Clicker »

Ozguxxx wrote: you may also need a memory manager.
i hardly see why a memory manager is needed in order to implement input reading ...
Whatever5k

Re:user inputs

Post by Whatever5k »

i hardly see why a memory manager is needed in order to implement input reading ...
Well, depends...the question is: how much code can you write without needing dynamic allocated memory
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:user inputs

Post by Pype.Clicker »

i think having a buffer (which can be allocated statically without any problem) and handling interrupt doesn't require any dynamic memory allocation ...
Ozguxxx

Re:user inputs

Post by Ozguxxx »

I thought it was not only about dynamic memory (but it cn also be a consideration) but my idea was that your terminal driver will need some static memory for saving its data for and so that it might somewhere need to communicate with the memory manager software in the system. But I also aggree in the sense that you will not very urgently need a memory manager. Do you agree?
Mastermind

Re:user inputs

Post by Mastermind »

Ozguxxx wrote: I thought it was not only about dynamic memory (but it cn also be a consideration) but my idea was that your terminal driver will need some static memory for saving its data for and so that it might somewhere need to communicate with the memory manager software in the system. But I also aggree in the sense that you will not very urgently need a memory manager. Do you agree?
Yes, I agree (and thanks to all who have replied). I know that you can use assembly language to do the same thing (get input). I did that before, but in an all-asm kernel. Does anyone know how I could insert asm code in my c kernel?
chrisa128

Re:user inputs

Post by chrisa128 »

Rewrite it in C...

First you need to write an interrupt handler to place the key into a buffer.
Second you need to write a getch that checks to see if the buffer is empty and if not returns the value stored in it and empties it.
Post Reply