How to make a simple OS in Assembly

111 views
Skip to first unread message

MANTITA

unread,
May 22, 2020, 8:41:47 AM5/22/20
to MikeOS
Using a tutorial from the MikeOS site, I was able to make an Operating System that could print text on the screen.
At the time that was a big achievement, but now I would like my OS to be usable and interactive.
My question is - How do you add user input in assembly? Because I would like to add some sort of functionality into my OS.
Sorry, I am not very good at assembly.
I looked all over the internet, but couldn't find anything.
Somebody Help!

Pete Dietl

unread,
May 22, 2020, 12:31:20 PM5/22/20
to MANTITA, MikeOS
To perform user input, you need to interface with the keyboard controller. A good source of information on this is topic can be found at the following links:
It’s pretty simple in principle, but contains a lot of details. In short, you use Port-IO to communicate to and from the keyboard controller. You can get user input by polling the keyboard controller until input is received, or you can set up interrupts to get the input asynchronously.

--
You received this message because you are subscribed to the Google Groups "MikeOS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mikeos+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/mikeos/e68fcddc-1d57-42a0-b58b-ab06510e5833%40googlegroups.com.

Michal Procházka

unread,
May 22, 2020, 1:50:52 PM5/22/20
to MikeOS
A really simple solution (which MikeOS itself uses) is the 16h interrupt, function 0. It's simple: you call it, it waits for a keypress and then returns the ASCII value of that key in the AL register.

Example code:

    mov ah, 0          ; We're telling the BIOS that we want to wait for a keypress
    int 16h            ; Call the BIOS (16h = keyboard routines)

    cmp al, 13         ; Has the Enter key been pressed? (13 = Enter ASCII code)
    je .enter_pressed  ; If it has, jump somewhere

Another fun thing you may try is the following loop, which will print on the screen whatever the user types:

loop:
    mov ah, 0          ; Get a keypress, as described above
    int 16h

    mov ah, 0Eh        ; We're telling the BIOS that we want to print the character, which is already in the AL register
    mov bh, 0          ; Set screen page 0 (it's good practice)
    int 10h            ; Call the BIOS (10h = video routines)

    jmp loop           ; Loop forever

Good luck!
Reply all
Reply to author
Forward
0 new messages