Search code examples
assemblyfasm

assembler (fasm) - read character


the bios interrupt function 21h (ah = 1h) should read a character from the standart input and echo it.

My read function:

    mov ah, 1h
    int 21h

So, if i press a key it realises that, but it won't echo a character. Since im using my code to boot it from my floppy and the character echo function int 10h (ah = 0eh), i think i have to store it and then echo it with the "video - teletype output" (int 10h (ah = 0eh)).

Or did i miss something in the aboce code?


Solution

  • Interrupt 0x21 is an 'interface' to MSDOS-like OS functions, not the BIOS.

    If you are writing the real-mode bootloader or a small OS kernel, you have to use your own IRQ 1 handler.

    See this answer for the way to capture all the keypresses in your own memory buffer: How to check keys status in x86 assembly?

    Then you will have to arrange some sort of a loop. You check for key press (by reading the memory buffer). Once the keypress is detected, to print the "echoed" key you have to write something to the video memory. That's another story. If you're using the default text mode, just write to the 0xB800 segment. If you're using the graphics mode (VGA or VESA), then you have to get raster font from somewhere.

    If you are writing things in assembly at the bootloader level, there is not much available. Definitely not the int 0x21.