Page 2 of 2
Re: BIOS calls and registers
Posted: Wed Oct 15, 2014 4:05 am
by mallard
Any "MS-DOS compatible" OS is will require BIOS (or provide an emulation of one). Almost all DOS programs (and many parts of DOS itself) use BIOS services. DOS itself doesn't provide anything like a complete API for programming the PC and was designed to be used in conjunction with the BIOS. Even if the OS could be made BIOS-independent, there would be very few DOS applications that would run without it.
Basically, "DOS" without the BIOS would be almost completely useless.
Re: BIOS calls and registers
Posted: Wed Oct 15, 2014 4:08 am
by elderK
It seems the topic has run far off course.
To return to the original question: Are there any registers whose contents I can be sure will be preserved when utilizing a BIOS call?
RBIL doesn't mention what registers are preserved, etc, when describing E820. Naturally, I assume all the ones it doesn't mention as being altered or used by the call, are preserved.
But how sure can I be of that?
~K
Re: BIOS calls and registers
Posted: Wed Oct 15, 2014 4:39 am
by b.zaar
elderK wrote:RBIL doesn't mention what registers are preserved
Every register not mentioned is preserved, SS & SP is saved by the int XX.
RBIL is the BIBLE about interrupts, if something is not mentioned there you'll have to search the BIOS source code directly.
Re: BIOS calls and registers
Posted: Wed Oct 15, 2014 5:16 am
by Antti
b.zaar wrote:Every register not mentioned is preserved
I would say it is not a good idea to trust that. I could write a code snippet like this:
Code: Select all
RandomByteVal equ 0x12
RandomAddrOff equ 0x1234
RandomAddrSeg equ 0x4321
ExampleCode:
mov ax, RandomAddrSeg
mov ds, ax
cmp byte [RandomAddrOff], RandomByteVal
jne SafeBranch
call TurnOffTheSun ; THIS MUST NOT BE CALLED!
SafeBranch:
I am almost sure the Sun is not turned off. Do I like to have this kind of code? No.
Re: BIOS calls and registers
Posted: Wed Oct 15, 2014 12:24 pm
by b.zaar
Antti wrote:b.zaar wrote:Every register not mentioned is preserved
I would say it is not a good idea to trust that. I could write a code snippet like this:
Code: Select all
RandomByteVal equ 0x12
RandomAddrOff equ 0x1234
RandomAddrSeg equ 0x4321
ExampleCode:
mov ax, RandomAddrSeg
mov ds, ax
cmp byte [RandomAddrOff], RandomByteVal
jne SafeBranch
call TurnOffTheSun ; THIS MUST NOT BE CALLED!
SafeBranch:
I am almost sure the Sun is not turned off. Do I like to have this kind of code? No.
I'm not sure what your point is here? Where is the bios interrupt and which register did it corrupt?
Re: BIOS calls and registers
Posted: Wed Oct 15, 2014 11:33 pm
by Antti
b.zaar wrote:I'm not sure what your point is here? Where is the bios interrupt and which register did it corrupt?
The point was to show that code could be safe in practice. If you accept that quality level, then it is perfectly fine. Most of the programmers do that. Saying that all the registers not mentioned are preserved is not something that I would assume.
It is not too difficult to write code that does not care whether registers are preserved or not. I will assume that registers cs, ss, and sp are preserved if calling BIOS interrupt services.
Re: BIOS calls and registers
Posted: Thu Oct 16, 2014 2:33 am
by b.zaar
Antti wrote:
The point was to show that code could be safe in practice. If you accept that quality level, then it is perfectly fine. Most of the programmers do that. Saying that all the registers not mentioned are preserved is not something that I would assume.
It is not too difficult to write code that does not care whether registers are preserved or not. I will assume that registers cs, ss, and sp are preserved if calling BIOS interrupt services.
The bios has been around a long time and I think if it couldn't be trusted there's a lot of software out there since 1981 that has been very lucky when using it.
Feel free to browse the bochs bios source code though
Bios shouldn't be trusted any less than dos, Amiga os, os/2 or even any c library you use.