In: Computer Science
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
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'.