Task: Implementing the toupper()
Function
Navigate to tasks/to-upper/support/
.
We aim to implement the toupper()
function, which converts lowercase letters to uppercase. To do this, start with the to_upper.asm
file from the lab exercises archive and complete the body of the toupper()
function.
The string used is mystring
, and we assume it is a valid string. This string is passed as an argument to the toupper()
function when called.
Perform the transformation in place; there is no need for another string.
NOTE_ To convert a lowercase letter to uppercase, you need to subtract
0x20
from its value. This is the difference between lowercase and uppercase letters; for example,a
is0x61
, andA
is0x41
. You can see this in the ASCII manual page.To read or write byte by byte, use the
byte [reg]
construction as seen in the implementation of determining the length of a string in theprint_string_length.asm
file, where[reg]
is the pointer register storing the address of the string at that point.Stop when you reach the value
0
(NULL
byte). For checking, you can usetest
as seen in the implementation of determining the length of a string in theprint-string-length.asm
file.
Bonus: toupper()
Only for Lowercase Letters
Implement the toupper()
function so that the transformation occurs only for lowercase characters, not uppercase letters or other types of characters.
If you’re having trouble solving this exercise, go through this reading material.