Question

In: Computer Science

Convert the following pep/9 machine language program into an assembly code. Determine the output of this...

Convert the following pep/9 machine language program into an assembly code. Determine the output of this program if the input is ‘tab’. The left column is the memory address of the first byte on the line:

0000 D1FC15

0003 F1001F

0006 D1FC15

0009 F10020

000C D1FC15

000F F10021

0012 D10020

0015 F1FC16

0018 D1001F

001B F1FC16

001E 00

Solutions

Expert Solution

Address(in hex.)

Instruction in hex.

Instruction in binary

Meaning of the instructions

0000

D1FC15

1101 0001 1111 1100 0001 0101

Instruction = 1101 0001

1101 = Load byte r(8..15) from memory (1 byte from memory referenced by the operand to right half of the accumulator)

raaa=0001.

r=0(means load to accumulator)

aaa=001(means direct addressing)

operand=1111 1100 0001 0101

FC15=refers input device(keyboard)

Load a byte(character ‘t’) from key board

0003

F1001F

1111 0001 0000 0000 0001 1111

Instruction = 1111 0001

1111 = Store byte r(8..15) to memory (Store the right half of the accumulator(1 byte) to memory referenced by the operand)

raaa=0001.

r=0(means store from accumulator)

aaa=001(means direct addressing)

operand= 0000 0000 0001 1111

Store(print) byte stored in the right half of the accumulator into memory address 001F.

Since recently ‘t’ is stored in the right half of the accumulator, ‘t’ will be stored at memory address 001F.

0006

D1FC15

1101 0001 1111 1100 0001 0101

Load a byte(character ‘a’) from key board

0009

F10020

1111 0001 0000 0000 0010 0000

Store(print) byte stored in the right half of the accumulator into memory address 0020.

Since recently ‘a’ is stored in the right half of the accumulator, ‘a’ will be stored at memory address 0020.

000C

D1FC15

1101 0001 1111 1100 0001 0101

Load a byte(character ‘b’) from key board

000F

F10021

1111 0001 0000 0000 0010 0001

Store(print) byte stored in the right half of the accumulator into memory address 0021.

Since recently ‘b’ is stored in the right half of the accumulator, ‘b’ will be stored at memory address 0021.

0012

D10020

1101 0001 0000 0000 0010 0000

Load a byte from memory address 0020

Since Byte(character) stored at 0020 is ‘a’, ‘a’ will be stored into the right half of the accumulator.

0015

F1FC16

1111 0001 1111 1100 0001 0110

FC16=refers output device(console or screen)

Store(print) byte stored in the right half of the accumulator to screen.

Since recently ‘a’ is stored in the right half of the accumulator, ‘a’ will be printed to the screen.

0018

D1001F

1101 0001 0000 0000 0001 1111

Load a byte from memory address 001F

Since Byte(character) stored at 001F is ‘t’, ‘t’ will be stored into the right half of the accumulator.

001B

F1FC16

1111 0001 1111 1100 0001 0110

FC16=refers output device(console or screen)

Store(print) byte stored in the right half of the accumulator to the screen.

Since recently ‘t’ is stored in the right half of the accumulator, ‘t’ will be printed to the screen.

001E

00

0000 0000

Stop execution

Input: tab

Output: at

Therefore, the given pep/9 program takes input 'tab' and prints 'at'.


Related Solutions

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...
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++)...
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; }
write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
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: #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; }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT