[comp.sys.handhelds] Converting a string to uppercase.

grue@cs.uq.oz.au (Frobozz) (04/26/91)

hiya,

Somebody recently posted a user level RPL program that attempted to convert
from lower case to upper case.  Jan Brittenson pointed out that this program
didn't work as advertised for some of the special characters.  Well, what I've
done is to write a machine code program.  This program has been written to
run quickly (as opposed to being short, but at 85 bytes I don't think anybody
will mind all that much...the slower version would be a few bytes shorter :-)
it can handle a 4000 character string, changing every character from lower case
to upper case in less than 1 second;  it would be even faster on strings that
had capitals in them already.

This routine does check that it is passed a string (sorry, the error message
isn't quite up to scratch, it is hard to get it right --- Rick Grevelle sent
a message recently that kind of discussed this, well really it talked a lot
more about other issues and just said that this was hard ;-) and it works
correctly for any length string (it is very very fast for zero length ones ;-)

If anybody finds a bug in this, please tell me.  I haven't found one and I've
tried every character possible, but you never know for sure.  I grant unlimited
non-profit usage of this little routine to anybody who cares to use it (given
how simple the algorithm is it wouldn't be difficult to regenerate the program)

Is there any call for a string to lower case routine as well?  It would be
a very simple modification to this piece of code.


This following string should be in ASC format.  I added the checksum by
hand and I also added the line breaks by hand so this may not work as
desired.

"D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8
AAE4D71643106AE514A9EC0331B79EAD131FD9EAE1317F9625131FF962C0310E
A6A148161CF8AF2C8F2D760142164808CB2130B2130BDE1"


This is the string that I typed into my calculator (minus the newlines).
I am quite confident that this really does work correctly.  This string
does not have the checksum present and it isn't broken into new lines as
desired.

D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8AAE4D71643106
AE514A9EC0331B79EAD131FD9EAE1317F9625131FF962C0310EA6A148161CF8AF2C8F2D760142
164808CB2130B2130




        						Pauli
seeya

Paul Dale               | Internet/CSnet:            grue@cs.uq.oz.au
Dept of Computer Science| Bitnet:       grue%cs.uq.oz.au@uunet.uu.net
Uni of Qld              | JANET:           grue%cs.uq.oz.au@uk.ac.ukc
Australia, 4072         | EAN:                          grue@cs.uq.oz
                        | UUCP:           uunet!munnari!cs.uq.oz!grue
f4e6g4Qh4++             | JUNET:                     grue@cs.uq.oz.au
--

grue@cs.uq.oz.au (Frobozz) (04/28/91)

In <1009@uqcspe.cs.uq.oz.au> I write:
[lots of stuff]

oops, I made a nice error.  I forgot to post the checksums for the thing.

When the program is recalled to the stack, and BYTES is executed I get:
# 1EDBh and 85.5 on the stack.  If I run BYTES on 'STRUP' (which is where
I stored it), I get the same checksum and a length of 95.

The string (at the bottom, not the ->ASC one) has a checksum of # CB14h
[ This may not actually be correct, I've deleted the string from my calc
already and I scribbled this down before I did.  I hope it is correct ]

I suppose I should include some usage information:
On entry level 1 of the stack contains a string.  On exit this string is
changed so that all lowercase characters have become uppercase.




The program again in ->ASC format
"D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8
AAE4D71643106AE514A9EC0331B79EAD131FD9EAE1317F9625131FF962C0310E
A6A148161CF8AF2C8F2D760142164808CB2130B2130BDE1"


This is the string that I typed into my calculator (minus the newlines).
I am quite confident that this really does work correctly.  This string
does not have the checksum present and it isn't broken into new lines as
desired.

D9D20ECE81D0040D9D2075660CCD20380008FB9760147134164146819F2CECE8AAE4D71643106
AE514A9EC0331B79EAD131FD9EAE1317F9625131FF962C0310EA6A148161CF8AF2C8F2D760142
164808CB2130B2130



        						Pauli
seeya

Paul Dale               | Internet/CSnet:            grue@cs.uq.oz.au
Dept of Computer Science| Bitnet:       grue%cs.uq.oz.au@uunet.uu.net
Uni of Qld              | JANET:           grue%cs.uq.oz.au@uk.ac.ukc
Australia, 4072         | EAN:                          grue@cs.uq.oz
                        | UUCP:           uunet!munnari!cs.uq.oz!grue
f4e6g4Qh4++             | JUNET:                     grue@cs.uq.oz.au
--