Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you Correct the code: PLEASE help Pep/8 can be downloaded here: http://compu

ID: 3865405 • Letter: C

Question

Can you Correct the code: PLEASE help

Pep/8 can be downloaded here: http://computersystemsbook.com/software-downloads/

my while loop will not end:

num: .EQUATE 0

main: LDA 0,i

SUBSP 2,i

LDA 5,i

STA num,s

while1: LDA 0,i

LDA num,s

ADDA 1,i

STA num,s

STRO msg1,d

DECO num,s

CHARO ' ',i

BR while1

STRO msg2,d

msg1: .ASCII " -loop value- inside the loop is Less Than -condition value- "

msg2: .ASCII " Loop done, -loop value- equal or exceeds -condition value-"

.END

------------------------------------------------------

for this code only '$' will print:

BR main

ch: .EQUATE 2 ;

main: Subsp 1,i

CHARI ch,d

LDA 0,i

LDx ch,d

if: CPA 'A',i ; if((ch>='A')

BRLT else

LDx ch,d

CPA 'Z',i ;&&((ch<='Z')

BRGT elseif

then: STRO msg1,d ; cout<<'A'

BR endIf

elseif: LDx ch,d

CPA 'a',i ; if((ch>='a')

BRLT else

LDx ch,d

CPA 'z',i ;&&((ch<='z')

BRGT else

then2: STRO msg2,d ; cout<<'a'

BR endIf

else: STRO msg3,d ; cout<<'$'

endIf: STOP

CHARO ' ',i ; << endl

STOP

msg1: .ASCII "A"

msg2: .ASCII "a"

msg3: .ASCII "$"

.END

Explanation / Answer

i have modified the code and now it is correct

num: .EQUATE 0

main: LDA 0,i

SUBSP 2,i

LDA 5,i

STA num,s

while1: LDA 0,i

LDA num,s

ADDA 1,i

STA num,s

STRO msg1,d

DECO num,s

CHARO ' ',i

BR while1

STRO msg2,d

msg1: .ASCII " -loop value- inside the loop is Less Than -condition value- "

msg2: .ASCII " Loop done, -loop value- equal or exceeds -condition value-"

.END

------------------------------------------------------

for this code only '$' will print:

BR main

ch: .EQUATE 2 ;

main: Subsp 1,i

CHARI ch,d

LDA 0,i

LDx ch,d

if: CPA 'A',i ; if((ch>='A')

BRLT else

LDx ch,d

CPA 'Z',i ;&&((ch<='Z')

BRGT elseif

then: STRO msg1,d ; cout<<'A'

BR endIf

elseif: LDx ch,d

CPA 'a',i ; if((ch>='a')

BRLT else

LDx ch,d

CPA 'z',i ;&&((ch<='z')

BRGT else

then2: STRO msg2,d ; cout<<'a'

BR endIf

else: STRO msg3,d ; cout<<'$'

endIf: STOP

CHARO ' ',i ; << endl

STOP

msg1: .ASCII "A"

msg2: .ASCII "a"

msg3: .ASCII "$"

.END

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote