51 MCU assembly language: What are the control transfer instructions?

Publisher:悠闲自在Latest update time:2013-05-16 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Jump Instructions

Short jump instruction AJMP addr11

                   PC←addr11, jump range 2k

Long jump instruction LJMP addr16

                   PC←addr16, jump range 64k

Indirect jump instruction JMP @A+DPTR

                   PC←(A)+(DPTR)

Relative transfer instruction SJMP rel


Conditional branch instructions

JZ rel ;(A)=0,transfer

JNZ rel ; (A) ≠ 0, transfer

JC rel ; if C=1, transfer

JNC rel ; if C=0, transfer

JB bit, rel; if bit=1, transfer

JNB bit, rel; if bit=0, transfer

JBC bit, rel; if bit=1, transfer and bit=0


Compare Not Equal Jump Instruction

CJNE A, #data, rel; (A)=#data, continue C←0 (A)>#data, transfer to C←0 (A)<#data, transfer to C←1

                    Features: Only when <, C←1

CJNE A, direct, rel

CJNE Rn,#data,rel

CJNE @Ri, #data,rel


Decrement 1, if not equal to 0, jump instruction

DJNZ Rn, rel ;

DJNZ direct, rel


Example: Delay subroutine

    delay: MOV R7, #03H

    delay0: MOV R6, #19H

    delay1: DJNZ R6, delay1 

    DJNZ R7, delay0

    RET

 

Call subroutine instruction

Short call instruction ACALL addr11

Long call instruction LCALL addr16

Subroutine return instruction RET

Interrupt return instruction RETI

No operation instruction NOP

Reference address:51 MCU assembly language: What are the control transfer instructions?

Previous article:Distributed wireless gas monitoring device based on single chip microcomputer
Next article:51 MCU assembly language: What are the bit operation instructions?

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号