Translate program from C++ to Pep/8

S2009

Beta member
Messages
1
This is problem 13 out of book Computer Systems by Warford fourth edition. I am suppose to translate this C++ program into Pep/8


#include <iostream>
using namespace std;

int maint(){
char ch;
cin >> ch;
if((ch >= 'A') && (ch <= 'Z')){
cout << 'A';
}
else if((ch >= 'a') && (ch <= 'z')){
cout << 'a';
}
else{
cout << '$';
}

cout << endl;
return0;
}


This is what I have but it keeps printing out $



BR main
ch: .EQUATE 0
;
main: CHARI ch,d
LDA ch,d
if: CPA 'A',i
BRLT elseif
LDA ch,d
CPA 'Z',i
BRGT elseif
STRO msg1,d
BR endIf
elseif: LDA ch,d
CPA 'a',i
BRLT else
LDA ch,d
CPA 'z',i
BRGT else
STRO msg2,d
BR endIf
else: STRO msg3,d
endIf: STOP
msg1: .ASCII "A\x00"
msg2: .ASCII "a\x00"
msg3: .ASCII "$\x00"
.END
 
Back
Top Bottom