linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jeff <jko@bsn1.net>
Cc: linux-assembly@vger.kernel.org
Subject: Re: newbie question
Date: Sat, 3 Sep 2005 10:36:36 -0700	[thread overview]
Message-ID: <200509031036.37074.jko@bsn1.net> (raw)
In-Reply-To: <7bd86613aa9166680282e502f1d2d11b@wanadoo.fr>

On 09/03/2005 10:16 am, raphael wrote:
> I would like to know how i can manage to read the entry
> on the keyboard without using C functions like scanf or get.

You can use kernel calls.  The keyboard operates in two
modes and you need to select the mode first.

In raw mode each key press is provided.  In cooked mode
a whole line of data is provided when <enter> key pressed.

There are lots of examples, but the code looks like this:
 1. select mode, save previous mode
 2. wait for key press
 3. restore mode

Here is some code from asmlib.  It shows handling of multi
byte keys and the mouse.  This is probably does more than
you want, but may be useful.

  [section .text]

 extern raw_set2
 extern raw_unset2
 extern kbuf
 extern key_poll
 extern mouse_check
 extern poll_rtn
 extern kbuf_end
 extern key_flush
     

;   read_stdin - read stdin data to "kbuf"
; INPUTS
;   none
; OUTPUT
;   kbuf - contains keys read with zero termination
; NOTES
;    source file: read_stdin.asm
;
;    read_stdin calls raw_set2 to put keyboard in  raw
;    mode.  It then reads data to "kbuf" and calls
;    "raw_unset2 to restore terminal state.
;
  global read_stdin
read_stdin:
  call	raw_set2			;set raw mode and save previous mode
km_10:
  mov	ecx,kbuf
more_keys:
  mov	eax,3			;kernel read call
  mov	edx,1			;read one byte
  mov	ebx,0			;read stdin
  int	80h
  or	eax,eax
  js	km_15
  add	ecx,eax			;advance buffer ptr
  call	key_poll
  test	byte [poll_rtn],8	;check for error
  jz	km_20
km_15:
  call	key_flush
  jmp	short km_10
km_20:
  cmp	ecx,kbuf_end
  je	k_exit			;exit if buffer full
  test	byte [poll_rtn],1
  jnz	more_keys
k_exit:
  mov	byte [ecx],0		;terminate string
  call	mouse_check		;check if mouse data read
  call	raw_unset2
  ret 


  reply	other threads:[~2005-09-03 17:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-03 17:16 newbie question raphael
2005-09-03 17:36 ` jeff [this message]
2005-09-03 20:10   ` Martin Fflores
2005-09-03 20:10   ` Reading at port 60h Martin Fflores
2005-09-04  2:56     ` Richard Cooper
     [not found] <Pine.VMS.3.91-2(vms).1030228001923.25337A-100000@cs.felk.cvut.cz>
2003-02-28  0:45 ` Newbie Question Dragan Stancevic
  -- strict thread matches above, loose matches on Subject: below --
2003-02-27 22:57 dAvId KeDrOsKy
2003-02-27 23:19 ` Dragan Stancevic
2003-02-27 23:26 ` Rudolf Marek
2003-02-27 23:42 ` Robert G. Plantz
2003-02-28  6:28   ` hpr
2003-02-28  0:27 ` Slack Traq
2002-10-24 21:42 dAvId KeDrOsKy
2002-10-24 22:15 ` Rudolf Marek
2002-10-24 23:43 ` Brian Raiter
2002-10-25  3:07   ` Robin Miyagi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200509031036.37074.jko@bsn1.net \
    --to=jko@bsn1.net \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).