On Mon, 2 Feb 2004, Arkady V.Belousov wrote:
> - inthndlr.c:
> ______________O\_/_________________________________\_/O______________
> /* Display String */
> case 0x09:
> {
> unsigned char c;
> unsigned char FAR *bp = FP_DS_DX;
>
> while ((c = *bp++) != '$')
> write_char_stdout(c);
>
> lr.AL = c;
> }
> _____________________________________________________________________
> O/~\ /~\O
>
> Using `c' after loop (and after write_char_stdout() call) breaks
> optimization, because compiler should now preserve value of `c' on stack.
> I suggest, better return old line "lr.AL = '$'". Also, both `c' and `*bp'
> are not required to be unsigned.
are you sure?
I'm looking at a disassembly of inthndlr.obj and I see this:
079F L$113:
079F 8E C2 mov es,dx
07A1 26 8A 07 mov al,es:[bx]
07A4 43 inc bx
07A5 3C 24 cmp al,0x24
07A7 74 67 je L$123
07A9 30 E4 xor ah,ah
07AB E8 00 00 call write_char_stdout_
07AE EB EF jmp L$113
...
0810 L$123:
0810 E9 3E 01 jmp L$156
...
0951 L$156:
0951 88 46 EA mov -0x16[bp],al
0954 E9 A8 05 jmp L$269
...
0EFF L$269:
0EFF 8B 46 EA mov ax,-0x16[bp]
0F02 8E 46 0A mov es,0xa[bp]
... (common code up to "ret")
As to your other comments, sorry they cost me too much time too evaluate;
since you refuse to test them yourself and they might actually just save 0
bytes. I'm all for saving code size but these micro-optimizations are just
too tricky, a compiler can already completely negate them.
So for each of your changes i'd have to ask myself and individually
evaluate.
1) is it correct?
using count = 8 - (scr_pos & 7)
could be -(scr_pos & 7) + 8
but count = (scr_pos & 7) ^ 7 + 1 is wrong (== (scr_pos & 7) ^ 8)
ok, make that ((scrpos & 7) ^ 7) + 1 then, or (~scrpos & 7) + 1
but it still doesn't help at all.
2) how much code does it really save?
in the above example they are all the same in terms of code size.
sorry -- I don't have the time for that now. I hope this is my last
comment on the subject, completely pointless to discuss this further.
You do have wcc now; at least you can answer 2) yourself.
Bart
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel