PROGRAM 7: MultiTap! Multitap is a text entry system for mobile phones which use
ID: 3868564 • Letter: P
Question
PROGRAM 7: MultiTap!
Multitap is a text entry system for mobile phones which uses the repeated pressing of the same key to cycle through the letters for that key. It is based on the following phone keyboard:
Write an HLA Assembly language program that implements the following function:
procedure multitap( myCharacter : byte ); @nodisplay; @noframe;
Your function should return in AX the integer converted value, as shown in the chart above. Be sure to support both the UPPERCASE and lowercase versions of the letters listed above. See the program dialogue shown below.
(Hint: Since we don't know about strings and arrays just yet, your program can safely assume that the data entered will be a single character, which greatly simplifies this problem)
(Further Hint: Since the run-stack doesn't allow for a byte-sized argument to be pushed and popped, you will need to change this function to use a larger, padded argument)
Feed Me: I
in Multi-tap, that's 444
Feed Me: g
in Multi-tap, that's 4
Feed Me: j
in Multi-tap, that's 5
Explanation / Answer
code:
program multitapProgram
#include("stdlib.hff")
procedure multitap( myCharacter : byte ); @nodisplay; @noframe;
begin multitap;
if((myCharacter='a') | (myCharacter='A'))
mov(2,ax);
elseif( (myCharacter='b') | (myCharacter='B'))
mov(22,ax);
elseif( (myCharacter='c') | (myCharacter='C'))
mov(222,ax);
elseif((myCharacter='d') | (myCharacter='D'))
mov(3,ax);
elseif( (myCharacter='e') | (myCharacter='E'))
mov(33,ax);
elseif( (myCharacter='f') | (myCharacter='F'))
mov(333,ax);
elseif((myCharacter='g') | (myCharacter='G'))
mov(4,ax);
elseif( (myCharacter='h') | (myCharacter='H'))
mov(44,ax);
elseif( (myCharacter='i') | (myCharacter='I'))
mov(444,ax);
elseif((myCharacter='j') | (myCharacter='J'))
mov(5,ax);
elseif( (myCharacter='k') | (myCharacter='K'))
mov(55,ax);
elseif( (myCharacter='l') | (myCharacter='L'))
mov(555,ax);
elseif((myCharacter='m') | (myCharacter='M'))
mov(6,ax);
elseif( (myCharacter='n') | (myCharacter='N'))
mov(66,ax);
elseif( (myCharacter='o') | (myCharacter='O'))
mov(666,ax);
elseif((myCharacter='p') | (myCharacter='P'))
mov(7,ax);
elseif( (myCharacter='q') | (myCharacter='Q'))
mov(77,ax);
elseif( (myCharacter='r') | (myCharacter='R'))
mov(777,ax);
elseif((myCharacter='s')) | (myCharacter='S'))
mov(7777,ax);
elseif( (myCharacter='t') | (myCharacter='T'))
mov(8,ax);
elseif( (myCharacter='u') | (myCharacter='U'))
mov(88,ax);
elseif((myCharacter='v') | (myCharacter='V'))
mov(888,ax);
elseif( (myCharacter='w') | (myCharacter='W'))
mov(9,ax);
elseif( (myCharacter='x') | (myCharacter='X'))
mov(99,ax);
elseif( (myCharacter='y') | (myCharacter='Y'))
mov(999,ax);
elseif((myCharacter='z') | (myCharacter='Z'))
mov(9999,ax);
else
mov(0,ax);
end multitap;
static
userChar: char;
begin multitapProgram;
stdout.put("Feed Me:");
stdin.getc(userChar);
multitap(userChar);
stdout.put("in Multi-tap, that's:",ax,nl);
end multitapProgram;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.