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

MultiSim / Assembly 8051 DJNZ / CJNE Basic Program Counter: Write an assembler p

ID: 3675735 • Letter: M

Question

MultiSim / Assembly 8051 DJNZ / CJNE Basic Program Counter:

Write an assembler program using MultiSim which utilizes the DJNZ instruction and a counter to add 0AH 5 times and store the result in register 6 of bank 1 using register addressing.

Which I completed:

;[ADDR ] HEXOP LABEL: Disassembly

[00000] D2D1 setb PSW.1

[00002] 7400 mov A, #00h

[00004] 7A05 mov R2, #05h

[00006] 240A AGAIN: add A, #0ah

[00008] DAFC djnz R2, AGAIN

[0000A] FE mov R6, A  

But the question I am stuck on is this:   Repeat problem 1 however this time instead of using the DJNZ instruction use the CJNE instruction. The DEC instruction or the INC instruction may be useful to you when writing code to do this. I need to convert the code I have above to use the CJNE instruction. Any help would be appreciated!

Explanation / Answer

CJNE instruction.. will compare and jump instruction

Normally syntax will be CJNE operand1 operand2 locationToJump

We have operand1 as R2, and we check with condition 01H and it jumps to AGAIN

we can use DEC operator , to decrement counter R2 to 1, and when it reaches 1, it will exits, otherwise it jumps to AGAIN

Here is the code

[00000] D2D1 setb PSW.1

[00002] 7400 mov A, #00h

[00004] 7A05 mov R2, #05h

[00006] 240A AGAIN: add A, #0ah

[00008] DAFC cjne R2,01h, AGAIN

[0000A] DEC R2, 01h

[0000C] FE mov R6, A

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote