os_input_string

52 views
Skip to first unread message

Mark M

unread,
May 27, 2021, 9:07:32 PM5/27/21
to MikeOS
I believe the documentation for os_input_string is missing the BX register.

Michael Saunders

unread,
May 28, 2021, 3:31:21 AM5/28/21
to Mark M, MikeOS
Hi Mark, can you provide more info please? I believe os_input_string
only takes AX as a parameter, and doesn't even use BX internally. And
all registers are restored before ret anyway...

On Fri, 28 May 2021 at 03:07, Mark M <mar...@wavecable.com> wrote:
>
> I believe the documentation for os_input_string is missing the BX register.
>
> --
> 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/10fa5615-aeeb-4502-9e37-7313845d5cb6n%40googlegroups.com.

Mark M

unread,
May 28, 2021, 3:22:59 PM5/28/21
to MikeOS
Well it didn't work when BX was 0.  Here is a section of mikedev.inc:

; String handling

os_int_to_string    equ    0018h    ; AX = unsigned integer, out AX = string
os_sint_to_string    equ    00C0h    ; AX = signed integer, out AX = string
os_string_reverse    equ    00AEh    ; SI = string location
os_string_length    equ    002Dh    ; AX = string loc, returns AX = length
os_string_uppercase    equ    0030h    ; AX = zero-terminated string
os_string_lowercase    equ    0033h    ; AX = zero-terminated string
os_input_string        equ    0036h    ; AX = string location, BX = maximum characters
os_string_copy        equ    0039h    ; SI = source, DI = dest strings
os_string_join        equ    003Fh    ; AX, BX = source strings, CX = dest
...

Wojciech G

unread,
May 28, 2021, 3:55:14 PM5/28/21
to MikeOS
Hi there, 
unfortunately, I've also learned about it, however in the most painful way - by looking it up in kernel code, after half an hour of trial and error.

So, the thing is, os_input_string takes BX register as a character count. I presume it was supposed to be safer than the old version, which had a static buffer, 255 bytes long. Now, it only reads into memory BX characters from the keyboard, and then it stops.

And now it's a bit of a shame because when you try to use it in your programs - you're most likely to use it at the beginning, and the kernel automatically sets all registers to 0 at startup. So you end up calling os_input_string with BX equal to zero, and it tries to get this many characters, thus immediately returns.

A quick look in CHANGES.TXT explains what happened: this feature was added in version 4.6, yet documentation wasn't accordingly updated. Hope it clears a picture a little bit.

Cheers, 
Wojtek.

Michael Saunders

unread,
May 29, 2021, 3:26:14 AM5/29/21
to Wojciech G, MikeOS
Oh yes, so it was added in 4.6 (I was looking at some code for 4.5),
but not properly documented. That's bad of me, as I take pride in
having extensive documentation. Oops. Sorry about that -- something
else to fix for 4.7...
> To view this discussion on the web, visit https://groups.google.com/d/msgid/mikeos/75737843-8393-4be6-a945-3735546020f9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages