Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

You are basically doing two different things:

  1. getting a character from keyboard
  2. Displaying it to the screen

Two different BIOS interrupts involved, but luckily, both using the same value in AL.

mov ah,0h   ;get character from keyboard
int 16h     ;and store it in AL
mov ah,0eh  ;Display a character in AL
int 10h     ;aka, echo it

INT 21h is a MSDOS thingy, which is a no-no if we are talking about bootloader.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top