Question

In: Computer Science

Translate the following C program to Pep/9 assembly language: #include <stdio.h> char toLower(char ch) { if...

Translate the following C program to Pep/9 assembly language:

#include <stdio.h>

char toLower(char ch)
{
if (ch >= 'A' && ch <= 'Z' )
       ch += 'a' - 'A';
return ch;
}

int main()
{
char ch, conversion;
printf("Enter an uppercase letter: ");
scanf("%c", &ch);
conversion = toLower(ch);
printf("\nLetter after conversion: %c\n\n", conversion);
return 0;
}

Solutions

Expert Solution

This is how to convert lower case letters to upper and vice-versa:
Code: In assembly language
.MODEL SMALL
        .DATA
                MSG  DB  0DH,0AH, \\ ENTER THE STRING :-----> :  $\'
                MSG2 DB  0DH,0AH, \' YOUR STRING IS  :-----> :  $\'
                STR1 DB  255 DUP(?)
                ONE  DB ?
                TWO  DB ?
          .CODE
BEGIN:
          MOV AX,@DATA
          MOV DS,AX
          LEA DX,MSG
          MOV AH,09H
          INT 21H
          LEA SI,STR1
          MOV AH,01H
READ:
          INT 21H
          MOV BL,AL
          CMP AL,0DH
          JE  DISPLAY
          XOR AL,20H
          MOV [SI],AL
          INC SI
          ;CMP BL,0DH
          JMP READ
DISPLAY:
          MOV AL,\'$\'
          MOV [SI],AL
          LEA DX,MSG2
          MOV AH,09H
          INT 21H
          LEA DX,STR1
          MOV AH,09H
          INT 21H
         ; MOV AH,4CH
         ; INT 21H
          .EXIT
END BEGIN

Related Solutions

Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number;...
Translate the following C program to PEP/9 assembly language. #include <stdio.h> Int main (){ int number; Scanf (“%d”, & number); if (number % 2 ==0) { printf (“Even\n”); } else { printf(“Odd\n”); } Return 0; }
Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1;...
Translate the following C++ program to Pep/9 assembly language. const char chConst = '+'; char ch1; char ch2; int main() { cin.get(ch1); cin.get(ch2);    cout << ch1 << chConst << ch2;    return 0; }
Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main(){ int numItms, j,...
Translate the following C program to Pep/9 assembly language. #include <stdio.h> int main(){ int numItms, j, data, sum; scanf("%d",&numItms); sum = 0; for(j = 1; j <= numItms; j++){ scanf("%d",&data); sum += data; } printf("Sum:%d\n",sum); return 0; } SAMPLE INPUT: 48-376 SAMPLE OUTPUT: Sum: 18
Translate the following C program to Pep/9 assembly language. #include <stdio.h.> int main() { int numitms,j,data,sum;...
Translate the following C program to Pep/9 assembly language. #include <stdio.h.> int main() { int numitms,j,data,sum; scanf("%d", &numitms); sum=0; for (j=1;j<=numitms;j++) { scanf("%d", &data); sum+=data; } printf("sum: %d\n",sum); return0; } I got an answer with an error. Please debug the answer or have a new correct answer (don't copy and paste others' answer) main: SUBSP 2,i DECI numItms,i DECI j,j DECI data,d DECI sum,s LDWA numItms,i sum: .EQUATE 0 LDWA 1,i STWA j,j for: CPWA numItms, j BRGE endFor STRO...
Take the following C++ program and translate it into Pep/9 assembly language #include using namespace std;...
Take the following C++ program and translate it into Pep/9 assembly language #include using namespace std; int age; char first, last; int main() {    cin >> age;    cin >> first >> last;    cout << "Your age " << age << endl;    cout << "Initials " << first << last << endl;    if (age >= 30)        cout << “Cannot trust\n”;    return 0; }
Take the following C++ program and translate it into PEP/9 assembly language #include <iostream> using namespace...
Take the following C++ program and translate it into PEP/9 assembly language #include <iostream> using namespace std; int num; char letter; int main() {    cin >> num;    cin >> letter;    cout << "You inputted " << num << endl;    cout << "Option " << letter << endl;    if (letter == '*')       cout << "Multiplied by 2 " << num*2 << endl;    return 0; }
Take the following program from C++ and translate it into Pep/9 assembly language: #include <iostream> using...
Take the following program from C++ and translate it into Pep/9 assembly language: #include <iostream> using namespace std; int theArray[] = { 5, 11, -29, 45, 9, -1}; void sumPos(int ary[], int len, int &sum) {    sum = 0;    for (int i = 0; i < len; i++)            if (ary[i] > 0)                sum = sum + ary[i]; } int main() {    int total;    sumPos(theArray, 6, total);    for (int k=0; k < 6; k++)...
1) Translate the following C program to Pep/9 assembly language. Please attach screenshot of Pep/9 simulator...
1) Translate the following C program to Pep/9 assembly language. Please attach screenshot of Pep/9 simulator running the program. #include <stdio.h.> int main() { int numitms,j,data,sum; scanf("%d", &numitms); sum=0; for (j=1;j<=numitms;j++) { scanf("%d", &data); sum+=data; } printf("sum: %d\n",sum); return0; }
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std;...
Take the following program and translate it into PEP/9 assembly language: #include <iostream> using namespace std; int theArray[] = { 5, 11, -29, 45, 9, -1}; void sumPos(int ary[], int len, int &sum) {    sum = 0;    for (int i = 0; i < len; i++)            if (ary[i] > 0)                sum = sum + ary[i]; } int main() {    int total;    sumPos(theArray, 6, total);    for (int k=0; k < 6; k++)      cout...
Take the following program and translate it into PEP/9 assembly language: #include using namespace std; int...
Take the following program and translate it into PEP/9 assembly language: #include using namespace std; int fib(int n) { int temp; if (n <= 0) return 0; else if (n <= 2) return 1; else { temp = fib(n – 1); return temp + fib(n-2); } } int main() { int num; cout << "Which fibonacci number? "; cin >> num; cout << fib(num) << endl; return 0; } You must use equates to access the stack and follow the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT