<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Keyboard input in DOS' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Keyboard input in DOS' posted on the 'x86 Assembly' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 13:22:09 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 13:22:09 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Keyboard input in DOS</title>
      <link>http://www.programmersheaven.com/mb/x86_asm/428488/428488/keyboard-input-in-dos/</link>
      <description>Hi there.&lt;br /&gt;
&lt;br /&gt;
I want to ask, how to get a keyboard input in DOS.&lt;br /&gt;
I have tried many of interrupts, with various AH values, but nothing works.&lt;br /&gt;
&lt;br /&gt;
Either it waits for a keystroke, or if a keystroke is present, it is not removed from the keyboard buffer.&lt;br /&gt;
&lt;br /&gt;
I want to develop a simple game. Is there any way to get a keystroke directly?&lt;br /&gt;
&lt;br /&gt;
Thanks for all ideas.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/x86_asm/428488/428488/keyboard-input-in-dos/</guid>
      <pubDate>Sat, 19 May 2012 01:26:04 -0700</pubDate>
      <category>x86 Assembly</category>
    </item>
    <item>
      <title>Re: Keyboard input in DOS</title>
      <link>http://www.programmersheaven.com/mb/x86_asm/428488/428489/re-keyboard-input-in-dos/#428489</link>
      <description>Hi and welcome.&lt;br /&gt;
&lt;br /&gt;
Interrupt 16h AH = 0 is the keyboard interrupt that will get deal with a keypress. When called, it waits for a keypress and returns the scancode of the key that was pressed in AH and the ASCII code of it in AL.&lt;br /&gt;
You say you've tried some interrupts.. have you tried this one?&lt;br /&gt;
&lt;br /&gt;
Sorry, just re-read your original post. If you don't want the computer to wait for a keypress, you could try int 16 AH = 1. I haven't tried it myself, but the descriptions I've found sound right for what you want.&lt;br /&gt;
&lt;br /&gt;
Thanks&lt;br /&gt;
Phillid</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/x86_asm/428488/428489/re-keyboard-input-in-dos/#428489</guid>
      <pubDate>Sat, 19 May 2012 01:45:05 -0700</pubDate>
      <category>x86 Assembly</category>
    </item>
    <item>
      <title>Re: Keyboard input in DOS</title>
      <link>http://www.programmersheaven.com/mb/x86_asm/428488/428492/re-keyboard-input-in-dos/#428492</link>
      <description>&lt;strong&gt;Phillid&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
I have tried this INT.&lt;br /&gt;
The problem is, if a keystroke is present, it is not removed from the keyboard buffer. Like holding (or pressing) this key forever.&lt;br /&gt;
&lt;br /&gt;
Can I clear somehow the keyboard buffer?&lt;br /&gt;
&lt;br /&gt;
Thanks for help.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/x86_asm/428488/428492/re-keyboard-input-in-dos/#428492</guid>
      <pubDate>Sat, 19 May 2012 03:02:49 -0700</pubDate>
      <category>x86 Assembly</category>
    </item>
    <item>
      <title>Re: Keyboard input in DOS</title>
      <link>http://www.programmersheaven.com/mb/x86_asm/428488/428495/re-keyboard-input-in-dos/#428495</link>
      <description>INT 16.01 should retrieve the keystroke from the keyboard buffer and also clear it from the buffer.  You may be doing something wrong in your testing.  Here's some code I have in several of my programs (the &amp;gt; is use in my assembler (A86) to indicate a forward label reference):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
;------------------------------------------------------------------------------
;FLUSH KEYBOARD BUFFER
;Inputs:
;Outputs:
;Changes: Flushes the Keyboard Buffer
;------------------------------------------------------------------------------
FlushKbdBuff:
  PUSH AX     ;Save used registers
F10:          ;Loop to here for each key
  CALL GetKey ;Get a key from the keyboard buffer
  JNZ  F10    ;If there was one, get another
  POP  AX     ;Restore used registers
  RET

;------------------------------------------------------------------------------
;READ CHARACTER FROM THE KEYBOARD BUFFER
;Inputs:
;Outputs: AH = Keyboard scan code
;         AL = ASCII value of keypress (0 if extended ASCII)
;         AX = 0 if no key is waiting
;Changes: ZF = Set if no key in buffer (AX = 0)
;            = Clear if a key was found (AX = key)
;------------------------------------------------------------------------------
GetKey:
  MOV  AH,1  ;Service 1 (Keystroke waiting?)
  INT  16h   ;Do It
  JZ  &amp;gt;K10   ;If no key waiting, we're done
  XOR  AH,AH ;If a key is waiting, service 0 (Get keystroke)
  INT  16h   ;Do It
  JMP &amp;gt;K90   ;We're done
K10:         ;No keystroke waiting
  XOR  AX,AX ;Make sure AX=0
K90:         ;We're done
  OR   AX,AX ;Set the found/not found flag
  RET
&lt;/pre&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/x86_asm/428488/428495/re-keyboard-input-in-dos/#428495</guid>
      <pubDate>Sat, 19 May 2012 08:42:33 -0700</pubDate>
      <category>x86 Assembly</category>
    </item>
    <item>
      <title>Re: Keyboard input in DOS</title>
      <link>http://www.programmersheaven.com/mb/x86_asm/428488/428528/re-keyboard-input-in-dos/#428528</link>
      <description>&lt;br /&gt;
&lt;strong&gt;Bret&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Thank you wery much!&lt;br /&gt;
It works.&lt;br /&gt;
I did not know, that I have to use the int 16h two times.&lt;br /&gt;
With AH 1 and next with AH 0.&lt;br /&gt;
Many thanks again.&lt;br /&gt;
Best regards.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/x86_asm/428488/428528/re-keyboard-input-in-dos/#428528</guid>
      <pubDate>Mon, 21 May 2012 05:17:50 -0700</pubDate>
      <category>x86 Assembly</category>
    </item>
  </channel>
</rss>