Translate the following C++ program to Pep/8 assembly language: #incl ude <iostr
ID: 3548861 • Letter: T
Question
Translate the following C++ program to Pep/8 assembly language:
#incl ude <iostream>
using namespace std;
int l ist[16];
int j, numItems;
int temp;
int main () {
cin >> numItems;
for (j = 0; j < numItems; j++) {
cin >> l ist[j];
}
temp = l ist[0];
for (j = 0; j < numItems - 1; j++) {
l ist[j] = l ist[j + 1];
}
l ist[numItems - 1] = temp;
for (j = 0; j < numItems; j++) {
cout << l ist[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.