Question

Identify and correct a linear and a subroutine programming error in given fragments of program to...

Identify and correct a linear and a subroutine programming error in given fragments of program to find the factorial of a number

ORG 0000H
LJMP 8000H
ORG 8000H
MOV A, 04H;
MOV R0, @A;
LCALL 8000H;
LCALL 3000H ;

ORG 9000H ;
FACT: CJNE R0, #01H, NEXT ;
RET;
NEXT: DEC R0 ;
MOV B, R0 ;
MUL AB ;
MOV R5, A
LJMP 9000H ;
END ;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The correct program is:

Address Label Instruction Comments
ORG 0000H
0000H LJMP 8000H Long jump at location 8000H
ORG 8000H
8000H MOV A,#04H MOV data 04H into A register
8002H MOV R0,A copy A into R0
8003H LCALL 9000H Long call at the location 9000H
8006H SJMP 8006H Short jump at 8006H location
ORG 9000H
9000H FACT: CJNE R0, #01H, NEXT compare R0 with 01H and jump at Next Label if R0 not equal to 01H
9003H RET Return to main prorram
9004H NEXT: DEC R0 Decrement R0 by 1
9005H MOV B, R0 Copy R0 into B
9006H MUL AB Multiply A and B
9007H MOV R5, A Store data of A into the register R5
9008H LJMP 9000H Long jump into 9000H
900BH END End of program
Add a comment
Know the answer?
Add Answer to:
Identify and correct a linear and a subroutine programming error in given fragments of program to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Note: The question needs to be answered in "C Programming Languange ". And after the question fin...

    Note: The question needs to be answered in "C Programming Languange ". And after the question find 3 pages for needed informations. Spring CE4717 Language Processors Q1. Consider the following LEx program. return R1 return R2 return R3 return R4 return R5; return R6; IA-2a-z)[A-Za-z0-9]- -2 10-91+ 10-9a-EA-FI Ihi] [01] [01] 이삐 t Vtin) int main (void) int tcode; do f tcode -yylex()i printf ("token type td \"%s\"\n", tcode, yytext); ) while (tcode)i return 0; i. Explain the steps needed...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT