Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 54:29:11 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,799 |
There's the obvious, from the existing code:[snip code]
Obviously I could just look for four trailing blanks (EAX), add 3 to ecx
on non-blank, look for two TB's (AX), and then for 1 TB (AL), but is there anything cleverer?
Robert,
There's the obvious, from the existing code:[snip code]
You're a bit light on information, so I have to make some assumptions :
"il_dloc" is a constant, holding the value 63
Your current strings all have the length 63 (in their first byte)
Danger will robinson, danger !
Assume an empty string, padded with 63 spaces. ECX will count down to Zero, and only you being lucky that the string-length byte is *not* 32 the loops check will exit.
Just imagine /someone/ has stored 32 spaces (padded with another 31 spaces) and correctly set the strings length. Yep, the string-length byte would
look like another space, causing ECX to underflow and wrap around. (don't
say never, as muphies law tries to tell us. :-) )
iow, for code less likely to bomb you need to check for ECX underflowing (becoming less than One) too.
-- part #2
Obviously I could just look for four trailing blanks (EAX), add 3 to ecx
on non-blank, look for two TB's (AX), and then for 1 TB (AL), but is there >> anything cleverer?
Not that I know of.
Other than getting rid of that "add 3 to ecx on non-blank" that is : assume that ECX points to the /last/ to-check character (start with il_dloc + 4)
and check it, and the three chars before it.
Don't forget to check for ECX underflow.
Though if speed is the target, you could take a look at "scasd" (moving "backwards" over the string), followed by a "scasw" and "scasb". More
setup (and teardown) needed, but /possibly/ faster in execution.
...Danger will robinson, danger !
The program is processing my own data, and there might be a handful of others using it
I think the overhead of SCASx is way too high for such short strings.
FWIW, the program runs in less than 0.5 seconds in the assembler-ised version, and in 0.75 seconds in the 99.9% pure Pascal version, and
speeding it up, ha, ha, ha, is just something to keep my mind engaged.