Since char values in HLA are just numeric equivalencies based on their ASCII cod
ID: 3919518 • Letter: S
Question
Since char values in HLA are just numeric equivalencies based on their ASCII code table value, you can manipulate character like you do any other numerical value.
For this program, I would like you to create a function which returns a character value based on a character parameter as shown below:
So in other words, UPPERCASE letters should become lowercase, lowercase letters should become UPPERCASE, number characters should be come an exclamation mark and all other characters should turn into an underscore. The converted letter should be stored in AL.
Write an HLA Assembly language program that implements the following function:
procedure converter( myCharacter : byte ); @nodisplay; @noframe;
Your function should return in AX the converted character value, as shown in the chart above.
(Hint: Since the run-stack doesn't allow for a byte-sized argument to be pushed and popped, you will need to envelope the argument in a larger eight bit argument. The converted letter should be stored into AL)
Feed Me: I
converted that's i
Feed Me: g
converted that's G
Feed Me: 1
converted that's !
Feed Me: #
converted that's _
Explanation / Answer
procedure converter ( myCharacter : byte ); @returns( "myCharacter" );
begin charInputFun;
if( chars.isLower( myCharacter ) ) then
chars.toLower( myCharacter );
elseif( chars.isUpper( myCharacter ) ) then
chars.toUpper( myCharacter );
elseif( chars.isDigit( myCharacter ) ) then
myCharacter := '!';
else
myCharacter := '-';
endif;
end charInputFun;