Re: Fastest way to highlight printable ASCII?
- From: Terje Mathisen <spamtrap@xxxxxxxxxx>
- Date: Fri, 07 Apr 2006 08:57:52 +0200
Jim Leonard wrote:
Terje Mathisen wrote:First: Is this actually intended for a real 8088 cpu?
Yes. I wouldn't be so concerned with printing strings quickly if it
weren't :-)
If so, then the only serious consideration is the size of your code,
since the actual runtime will always be pretty close to 4 clock cycles
multiplied by the total number of byte load or store operations,
including opcode bytes!
Well... a jump is 17 cycles, whereas one that "falls through" is 4, so
it's not quite that cut-and-dry I've been finding. But I hear you loud
and clear -- the only way I was truly able to eliminate CGA snow ended
up coming down between "MOV AX,BX" and "XCHG BX,AX" -- the XCHG was 1
byte shorter which gave me the time I needed.
The "sub al,33" comment was the main thing I was missing; it completely
eliminates one of the compares (I should know these tricks by now...
bangs head against wall).
The next optimization is to notice that in real life, most strings will
...except for these strings. The application in question is a binary
file viewer :-)
Even so, I believe you should do the statistics: If you average two or more characters between each change of range, then you should at least consider an unrolled loop for each type, which would mean that you only needed a single branch for each domain change.
consist of bytes from a single range, printable or not, and if you can
modify the last byte, then you can save the loop termination test on
each iteration:
Hey, something else I never thought of! This is a great approach,
except like I mentioned, the actual use for the code is viewing binary
files like .EXEs, etc. so the state will mostly be changing 10 times or
more per line. With that many state changes, I'm looking more toward
the lookup table approach since it will only require (127-33) bytes for
the table. I don't know how I'm going to address the table; probably
DB it right into the code and JMP around it or something.
Lookup tables aren't that good on 8088:
You want to modify the high half (AH), right? This means that you cannot simply use a plain XLAT, so you need more instructions and instruction bytes, plus the table load itself.
It might be a win, but I'm not at all sure!
Terje
--
- <Terje.Mathisen@xxxxxxxxxxxxx>
"almost all programming can be viewed as an exercise in caching"
.
- References:
- Fastest way to highlight printable ASCII?
- From: Jim Leonard
- Re: Fastest way to highlight printable ASCII?
- From: Terje Mathisen
- Re: Fastest way to highlight printable ASCII?
- From: Jim Leonard
- Fastest way to highlight printable ASCII?
- Prev by Date: Visual C++ inline asm far jmp
- Next by Date: Re: Disassembling BIOS to figure out a PCI error?
- Previous by thread: Re: Fastest way to highlight printable ASCII?
- Next by thread: Re: Fastest way to highlight printable ASCII?
- Index(es):
Relevant Pages
|