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, 01:33
(edited by Ninho on 13.05.2011, 01:46)

(snipping)
> Anyway, if your goal is to optimize the memory usage of this driver:
...
All done (credit Japheth), no fragmentation nor PSP remains in any case.

Other questions ? :=)


Since we are evoking byte shaving, let me start a small digression of a case hopefully not completely off topic and which might amuse or interest some readers. The original (keybgr) took care of saving/restoring the flags. That precaution probably seemed necessary to the seasoned (and cautious) professional programmer but, oyez! oyez! hear...!, both the clueless newbie (confused anyway with all that there interrupt stuff), AND... 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) :=)

The reason a software int 15h "hook" does not need to preserve the running flags is, of course, that no information is passed "down" thru them and, conversely, in cases information has to be passed back "up" to the (initial) caller, it is by altering the flags image put on the stack by the initial int 15 caller, not the running flags.

And why I'm bringing this fact here is that, indeed, the preserving/restoring of the flags around our int 15 hook was hardly a bug (it is useless but does no harm) and would not warrant a mention in the common case, nonetheless it is a a little lack of precision when one is... shaving bytes!

For anybody who wouldn't believe we do not need to pass the flags (received "from upwards") down the chain , while writing this I've been checking some int 15 "hooker", viz MS-Smartdrv (which is willing to catch the "3 finger salute" if you wonder why it hooks int 15). Well, MS got it right, it doesn't lose time in needlessly preserving the flags. Considering ~1 billion PCS have issued quadrillions of int 15s "through" Smartdrv, if their (and my) method were faulty you bet someone would've noticed :=)

Enough, sorry for the digression - I may've had a little wine too much

---
Ninho

 

Complete thread:

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