Question

on pour assium prtion Attempt each question onty oce Question 1: 120 Marks] CLO-02 Write an assembly language program to coun

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

Answer :- 1) The 8051 assembly code has been written below-

MOV R1, #40H ; register R1 = 0x40
MOV R2, #00H ; clear R2 register
MOV R3, #7FH ; R3 = 0x7F i.e. end address
Loop1 : ; label named as Loop1
MOV A, @R1 ; A = read memory address in R1
CJNE MakeZero ; if A is not zero, go to label named as MakeZero
INC R2 ; if A = 0 then increment the value in R2
INC R1 ; R1 = next memory address
CJNE R1, #7FH, Loop1 ; if R1 is not equal to 7FH then goto Loop1
JMP EndProg ; jump to label EndProg

MakeZero : ; label named as MakeZero
MOV A, #00H ; A = 0
MOV @R1, A ; make value as zero at address in R1
INC R1 ; R1 = next memory address
CJNE R1, #7FH, Loop1 ; if R1 is not equal to 7FH then goto Loop1

EndProg : ;label named as EndProg
MOV A, R2 ; copy the count value to the Accumulator
Here : JMP Here ; infiite loop, end of program

Add a comment
Know the answer?
Add Answer to:
on pour assium prtion Attempt each question onty oce Question 1: 120 Marks] CLO-02 Write an assembly language program t...
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
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