Question

Is there any interruption in assembly which read an input immediately (I mean without waiting for an enter and etc). For example: In java there is in the keylistener a function gives the ascii code of a key pressed without waiting to confirm the input. I work with assembly 8086, so answer in assembly 8086 is better.

Was it helpful?

Solution

If you are running on something with bios available, you can use int 16H:

mov al, 0
int 16h
; now al contains ascii-code of the key hit

See 20.4 The Keyboard BIOS Interface

OTHER TIPS

Example for to get an ASCII when pressing a key on our keyboard without using software-interrupts, but using an own ASCII-table:

KEYTAB DB 0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D
       DB 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1E,0x1F
       DB 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2B,0x2C,0x2D,0x2E,0x2F
       DB 0x30,0x31,0x32,0x33,0x34,0x35,0x39
       DB 0x56
tablen =  ($-KEYTAB)

ASCII DB "1234567890ß'"          ; table with language-specific letters
      DB "qwertzuiopü+as"
      DB "dfghjklöä^#yxcv"
      DB "bnm,.- "
      DB "<"
asclen  =  ($-ASCII)
;--------------------------------------------------

    cli
    in   al,0x64    ; get status
    test al,1       ; output buffer empty?
    jz  short NOKEY
    test al,0x20    ; PS2-mouse byte?
    jnz short NOKEY
    in   al,0x60    ; get one byte from keyboard
    sti

; using an own ASCII-table for to convert the keyboardcodes in AL to ASCII

NOKEY:

Dirk

There is a call command, in assembly, which works in certain assemblers and accesses the operating system keypress routine

call osrdch (Operating System Read Character)

8086 stuff is going back a looooong way though.... 1980?

If osrdch works for you then great but back then if you wanted anything at all you usually had to write it yourself or dig it out of the huge number of programmer magazines floating around newsagents back in them days

    call "osrdch" ;o-s read character

    call "oswrch" ;o-s write character

If the gods are with you that will plonk it onto the vdu display

The "int 16H" routine mentioned above is basically what it replicates, but your OS may not allow interrupts

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top