Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

AMIS, Optimize memory usage (Developers)

posted by Ninho E-mail, 13.05.2011, 11:27

Hullo Japheth

>> That precaution probably seemed necessary to the seasoned (and
>> cautious) professional programmer but,...
>> ... the "good (TM)" programmer (after carefully checking his facts)
> will
>> omit the flag save/restore (thereby reducing the size of the
> > resident KBFR by a whopping 6 bytes iirc) :=)

> Cool!


> This is true ............ to some degree. :))
>
> However ... there are a few considerations:
>
> - int 15h is an interrupt which is used for a lot of purposes.

Indeed the "cassette!" interrupt has been a place holder for an ever expanding number of system services. I consider it the BIOS analogous to DOS's int 2F multiplex ("printer.sys" was it not?)

> - there exists software, including BIOSes, which do NOT return
> from this interrupt by an IRET, but by a RETF 2.

Due to the above, a Retf 2 will make sense in certain cases of int 15h and not in others.

> - a lot of software sets (or resets) the carry flag BEFORE it calls Int
> 15h.

Ack, this is even prescribed in many cases of int 15. Case in point (15/4F) caller (normally an IRQ1 routine) is supposed to SET CY (and I have yet to SEE a firmware BIOS or software IRQ1 handler that doesn't) and our *hooker* returns status information thru the carry, that is the Cy bit of the flag image saved by the initial Int 15 instruction, not the current carry.

> ( this is probably done because there exist buggy hookers/BIOSes ).

Our hooker is not supposed to repair bugs in other software. The important point here is if some other int 15 hooker incorrectly thinks the Flags register passed to it holds meaningful information, there is /no/ general way whatever we do can repair that other software's bug, except in marginal circumstances. I thought this over in the 90s, and I even taught it.

Fortunately when considered in detail the scheme is not as fragile as it looks.

> So, considering these facts(?), one might come to realize that it is at
> least "thinkable" that saving the flags status is not absolutely useless. I
> guess - it was in 1993! - that was the reason why I added it.

This is well understood and why I said the "seasonned, cautious, professional..." would wish to pushf/popf just in case ;=)

Analysis and practice however show that it is in fact both unnecessary, from a functional PoV, and useless as a well meaning measure to "repair" others' bugs. If there was a 1/1,000,000 doubt in my mind, I would gladly put those miserable 6 bytes to the place where I took them off ;=)

Truly,

--
Ninho

---
Ninho

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 250 users online (1 registered, 249 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum