News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

making it writable

Started by bcddd214, December 22, 2011, 08:01:26 AM

Previous topic - Next topic

bcddd214

I put together my first OS and now toying with making it legit. I hit my first bug making it write able. The keyboard is gonna have to work some way.
I need to pull in the ASCII keys somehow.
If someone could flash some code up to me so that I could see how this is done, I would be eternally grateful.

bcddd214

Overview.

I created a blank screen, the blue screen has to be able to do something.

bomz


FORTRANS

Hi,

   If you are in real mode and can use the BIOS, here is some
information.  Functions 10H and 11H are similar to functions 0 and
1, but they support the 101 key keboard gray keys differently.

HTH,

Steve

"INT 16,00","Read Keyboard Input

   INT 16H is the keyboard services interrupt.  Function 0 is
the return a character from the keyboard.  If a character is
not in the input buffer, it will wait for one.  If the character
returned in AL is zero, then the key is a non-ASCII function
key.  If there is no key on entry, the 200LX will use the light
sleep function while waiting.

INPUT  AH = 0

OUTPUT AH = Scancode
       AL = Character or 0",""@

"INT 16,01","Check Keyboard Status

   Checks the input buffer to see if there is a key waiting.
If a key is available, the codes are returned in AX, but not
removed from the buffer.  If no key availble, the Zero Flag is
set.

INPUT  AH = 1

OUTPUT Zero Flag = 1, Buffer is empty
       Zero Flag = 0, AH = Scancode, AL = Character or 0",""@

bcddd214

Quote from: bomz on December 22, 2011, 09:07:26 AM
http://www.emu8086.com/



Wow, thank you. That is a little more than what I needed. I am afraid I do not have a: drive or even own one. I would like to produce pretty much the same effect without the kernel first.
Than I will play around with changing that to work on a cd-rom.
I think that if I can grasp making it more of a text editor first, my goal of being able to write it on my own is a little bit more achievable but this is a beautiful program.

bcddd214

Quote from: FORTRANS on December 22, 2011, 01:39:09 PM
Hi,

   If you are in real mode and can use the BIOS, here is some
information.  Functions 10H and 11H are similar to functions 0 and
1, but they support the 101 key keboard gray keys differently.

HTH,

Steve

"INT 16,00","Read Keyboard Input



do I place this in a proc or a macro?
How should I call on it?


bcddd214

I guess what is confusing me is that I was expecting to have to teach the program what ascii was.
INPUT  AH = 1

OUTPUT Zero Flag = 1, Buffer is empty
      Zero Flag = 0, AH = Scancode, AL = Character or 0",""@

makes sense, I am just expecting more to this.

bomz

My English is poor. I am not well understand what you want. Try emmulator - it show all very good

FORTRANS

Quote from: bcddd214 on December 23, 2011, 12:47:45 AM

"INT 16,00","Read Keyboard Input


do I place this in a proc or a macro?
How should I call on it?

   Hi,

   Something like the following.

Steve N.


; You want to poll the keyboard.
        MOV     AH,0
        INT     16H
        CMP     AL,0    ; Test for function keys.
        JE      FunctionKey
        ; AL has a code of a normal key (ASCII).
        ; Your code for processing an ASCII character.

FunctionKey:
        ; AH has the scan code of a function key.
        ; Your code for processing a function key like the cursor keys.

MichaelW

bcddd214,

Interrupt 16h function 0 and 10h are used to read keystrokes from the keyboard buffer. If a keystroke is available in the buffer then the functions remove it from the buffer and return the key scan code in AH and the character code translation in AL. If no keystroke is available (because the buffer is empty) then the functions wait for a keystroke before returning.

Interrupt 16h function 1 and 11h are used to check for the presence of a keystroke in the keyboard buffer. If a keystroke is available in the buffer then the functions clear the zero flag and return the key scan code in AH and the character code translation in AL. If no keystroke is available then the functions return with the zero flag set. Note that these functions do not remove keystrokes from the buffer.

Note that the keyboard buffer has a limited size, and that failure to remove keystrokes from the buffer may cause it to fill up and the BIOS to start discarding keystrokes.

For the simplest of uses, like waiting for a single key press before ending a program that otherwise does not accept keyboard input, interrupt 16h function 0 or 10h will work OK. But for a program that does accept other keyboard input, before using one of these functions to wait for the final key press you must first "flush" the keyboard buffer, leaving it empty, as otherwise these functions will not wait.

; -------------------------------------------------------------
; This proc calls the BIOS Read Keyboard Status and Read
; Keyboard Input functions to flush the keyboard buffer,
; wait for a key press, and then flush the buffer again,
; leaving it empty. The BIOS scan code for the key pressed
; is returned in AH and the character code in AL.
; -------------------------------------------------------------

waitkey proc c
  @@:
    mov ah, 1
    int 16h                   ; Check for key press
    jz  @F                    ; Jump if buffer empty
    mov ah, 0
    int 16h                   ; Get key
    jmp @B                    ; Repeat
  @@:
    mov ah, 1
    int 16h                   ; Check for key press
    jz  @B                    ; Repeat
    mov ah, 0
    int 16h                   ; Get key
    push ax                   ; Preserve it
  @@:
    mov ah, 1
    int 16h                   ; Check for key press
    jz  @F                    ; Jump if buffer empty
    mov ah, 0
    int 16h                   ; Get key
    jmp @B                    ; Repeat
  @@:
    pop ax                    ; Recover key
    ret
waitkey endp

eschew obfuscation

bcddd214

I think I got it using your code. I am hanging though??
http://pastebin.com/vm3n1LuP

MichaelW

The code does not hang for me - it's just a matter of providing the right inputs in the right sequence.
eschew obfuscation

bcddd214


MichaelW

The calls to makewin and curpos return without user input.

The call to waitkey requires that you press a key.

The call to mouse requires that you click the left mouse button with the mouse cursor at the upper left-hand corner of the screen (or window in windowed mode), and then press a key.

The call to getchar requires that you press a key.
eschew obfuscation