Translate this C++ program to Pep/8 assembly language: #include <iostream> using
ID: 3642993 • Letter: T
Question
Translate this C++ program to Pep/8 assembly language:
#include <iostream>
using namespace std;
int list[16];
int j. numItems;
int temp;
int main () {
cin >> numItems;
for (j = 0; j < numItems; j++) {
cin >> list[j];
}
temp = list[0];
for (j = 0; j < numItems - 1; j++) {
list[j] = list[j + 1];
}
list[numItems - 1] = temp;
for (j = 0; j < numItems; j++) {
cout << list[j] << ' ';
}
cout << endl;
return 0;
}
Explanation / Answer
BR main list: .BLOCK 32 ;global variable i: .BLOCK 2 ;global variable numItems: .BLOCK 2 ;global variable temp: .BLOCK 2 ;global variable ; ;****main() main: DECI numItems,d ;cin >> numItems LDX 0,i ;for (i = 0 STX i,d for1: CPX numItems,;i > list[i] LDX i,d ;i++ ADDX 1,i STX i,d BR for1 endFor1: ASLX LDX list,x ;temp = list[0] STX temp,d CPX 0,i ;for (i = 0 STX i,d for2: CPX numItems, ;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.