Presentation is loading. Please wait.

Presentation is loading. Please wait.

Conditional Jumps and Time Delays

Similar presentations


Presentation on theme: "Conditional Jumps and Time Delays"— Presentation transcript:

1 Conditional Jumps and Time Delays
Source:

2

3

4 Source: http://www.keil.com/support/man/docs/is51/is51_nop.htm

5 A single-loop time delay
“DJNZ” can be used here.

6 The DJNZ Instruction DJNZ byte, rel decrement and jump if not zero (PC) <- (PC) + instructionSize (byte) <- (byte) - 1 IF (byte) <> 0 THEN (PC) <- (PC) + rel 2-byte version, used with Rn, n = 0 7 3-byter version, used with RAM location DJNZ Rn, rel decrement and jump if not zero (PC) <- (PC) + 2 (Rn) <- (Rn) - 1 IF (Rn) <> 0 THEN (PC) <- (PC) + rel DJNZ direct, rel decrement and jump if not zero (PC) <- (PC) + 3 (direct) <- (direct) - 1 IF (direct) <> 0 THEN (PC) <- (PC) + rel 11011rrr rel bit add, rel DJNZ R5,rel DJNZ 30H, rel rel rel

7 MOV MOV R0, 0FFH DJNZ R0, $

8 A 2-loop time delay The overall number of iterations = N0 × N1

9 A 3-loop time delay

10 A 3-loop time delay ; *** The 3-loop time delay *** threeLoopDelay:
MOV R2, #0AH loop: CALL twoLoopDelay twoLoopDelay: ; **** The 2-loop time delay **** MOV R0, #0FFH loadR1: MOV R1, #0FFH DJNZ R1, $ DJNZ R0, loadR1 RET

11 JC & JNC JC rel jump if carry set (PC) <- (PC) + 2 IF (C) = 1 THEN (PC)< - (PC) + rel JNC rel jump if carry not set (PC) <- (PC) + 2 IF (C) = 0 THEN (PC) <- (PC) + rel

12 JZ & JNZ JZ rel jump if accumulator zero (PC) <- (PC) + 2 IF (A) = 0 THEN (PC) <- (PC) + rel JNZ rel jump if accumulator not zero (PC) <- (PC) + 2 IF (A) <> 0 THEN (PC) <- (PC) + rel

13 JB, JBC, & JNB JB JBC JNB PC = PC + 3 IF (bit) = 1 PC = PC + offset
JB P1.2 LABEL JBC P1.2 LABEL JNB P1.3, LABEL

14


Download ppt "Conditional Jumps and Time Delays"

Similar presentations


Ads by Google