Section | Assembly Challenges |
---|---|
Type | Leg Architechture |
Prerequisite | Stack |
Scored | No |
API | {{{api-enum-id}}} ({{{api-enum-number}}}) |
We had the intern type out planet names in human script. Unfortunately, he forgot to capitalize each name.
The inputs in this level represent the characters in a list of planet names, encoded as ASCII (see the manual). Each name is separated by a space which has the numeric value 32. Replace the first letter in each word with it's uppercase counterpart. (The possible input characters are a to z lowercase, space, apostrophe and dash)
All one has to do is read each character in and, if it follows a space, subtract 32 from its value in order to capitalize it, then output the result.
One approach to solving the level is:
- Load 32 into Register 0.
- Label the beginning of the loop.
- Read the input into Register 1
- If Register 0 = 32, subtract 32 from Register 1
- Output Register 1
- Copy Register 1 to Register 0
- Loop back to step 2.
As we pre-loaded a 32 in Register 0, in which we keep track of the last character we processed, it will capitalize the first character as if it had followed a space.