当前位置:网站首页>Pic16f877xa instruction system (assembly language)
Pic16f877xa instruction system (assembly language)
2022-07-25 06:20:00 【sinat_ twenty-six million five hundred and twenty-eight thousan】
Macro understanding
Core mnemonic
Mnemonic symbol Functional specifications English full name
ADD Add up add
SUB Subtracting the substract
RL Cyclic shift to the left rotate left
RR Cycle moves to the right rotate right
AND And and
IOR or inclusive or
XOR Exclusive or exclusive or
COM Take the opposite complement
INC Add 1 increase
DEC reduce 1 decrease
MOV delivery move
CLR Zero clearing clear
RET return return
BTF Bit test bit test
Instruction system supplementary character description
character Functional specifications English full name
W Working register ( I.e. accumulator ) -
f Register address ( take 7 Bit register address ,00H~7FH) -
b 8 Bit register f Internal address (0~7) bit
K Count now (8 Bit constant or 11 Bit address )、 Constant or label -
L The instruction operand contains 8 Immediately K -
d Destination address selection :d=0, Results to W;d=1, Results to f destination
FSZ register f by 0, Then jump between skip if 0
FSC register f Of b Position as 0, Then jump between skip if clear
FSS register f Of b Position as 1, Then jump between skip if set
( ) Represents the contents of a register -
(( )) Indicates the contents of register indirection -
→ Indicates that the operation result is sent to the target register -
Examples of common instructions
Chip manual
Register plus 1 Instructions :INCF
【 Format 】 INCF F,d
【 function 】 register F Add 1
【 explain 】
(1)INCF yes Increment F Abbreviation ;
(2) stay PIC series 8 Bit MCU , Common symbols F Represents various registers and F Serial number address of ;
(3)d=0 when , The result is deposited in W;d=1 when , The result is deposited in F.
【 example 】
INCF PORTC,1 ; take PORTC Add 1
Register minus 1 Instructions :DECF
【 Format 】 DECF F,d
【 function 】 register F reduce 1
【 explain 】
(1)DECF yes Decrement F Abbreviation ;
(2)d=0 when , The result is deposited in W;d=1 when , The result is deposited in F.
【 example 】
ENCODER EQU 0X21
……
DECF ENCODER,1 ; take ENCODER reduce 1
Register reset instruction :CLRF
【 Format 】 CLRF F
【 function 】 Register clear
【 explain 】
(1)CLRF yes Clear F Abbreviation ;
(2)F The register is cleared to all 0, Make the status bit Z=1.
【 example 】
CLRF TRISC ; Yes TRISC Zero clearing
W Clear command :CLRW
【 Format 】 CLRW
【 function 】 register W Zero clearing
【 explain 】
(1)CLRW yes Clear W Abbreviation ;
(2)W by PIC Working register of single chip microcomputer ;
(3)W The register is cleared to all 0, Make the status bit Z=1.
【 example 】
CLRW ;W=00H
F Register transfer instruction :MOVF
【 Format 】 MOVF F,d
【 function 】 take F Register contents are transferred to F or W
【 explain 】
(1)MOVF yes Move F Abbreviation ;
(2) When d=1 when , to F In itself ; When d=0 when , to W;
(3) Affect status bits Z
【 example 】
MOVF PORTB,0 ;PORTB Oral content delivery W
MOVWF PORTA ;W The content is PORTB Oral content delivery PORTA
W Register transfer instruction :MOVWF
【 Format 】 MOVWF F
【 function 】 W Register transfer
【 explain 】
(1)MOVWF yes Move W to F Abbreviation ;
(2) take W Register content transfer F,W The content remains the same ;
(3) Does not affect the status bit .
【 example 】
MOVLW 0x0B ; send 0BH send W
MOVWF PORTB ; send W Content to PORTB mouth
Incremental jump instruction :INCFSZ
【 Format 】 INCFSZ F,d
【 function 】 Incremental jump
【 explain 】
(1)INCFSZ yes Increment F,Skip if 0 Abbreviation ;
(2)F Add... To the contents of the register 1 after , When d=1 When the result is saved F, When d=0 I'll deposit it in W;
(3) If the result is 0 Skip the next instruction , Otherwise, execute in sequence ;
(4) Affect status bits Z.
【 example 】
LOOP INCFSZ COUNT1,1 ;COUNT1 Add 1, The results are stored in COUNT1
GOTO LOOP ; The result is not zero , loop
MOVWF COUNT2 ; When the result is zero , Execute the statement
Decrement jump instruction :DECFSZ
【 Format 】 DECFSZ F,d
【 function 】 Decrement jump
【 explain 】
(1)DECFSZ yes Decrement F,Skip if 0 Abbreviation ;
(2)F Register contents minus 1, The result is deposited in F In itself (d=1) or W(d=0);
(3) If the result is 0 Skip the next instruction , Otherwise, execute in sequence ;
(4) Affect status bits Z;
(5) In actual instructions , When d=1 when , This item is often omitted .
【 example 】
DELAY MOVLW 25 ; Delay subroutine
MOVWF N ; to N assignment 25
LOOP DECFSZ N,1 ;N-1 Return N And judge the result =0? yes ! Out of the loop
GOTO LOOP ; no ! Cycle back
RETURN ; return
Bit clear instruction :BCF
【 Format 】 BCF F,B
【 function 】 Positional clarity 0
【 explain 】
(1)BCF yes Bit Clear F Abbreviation ;
(2) Symbol B It means something in the film 8 Bit data register F Tag number of ( Or bit address );
(3) The command means : Set the... Of the register B Positional clarity 0.
【 example 】
BCF REG1,2 ; Put the register REG1 Of the 2 A reset
Location 1 Instructions :BSF
【 Format 】 BSF F,B
【 function 】 Location 1
【 explain 】(1)BSF yes Bit Set F Abbreviation ;
(2) Register F Of the B Location 1.
【 example 】
BSF STATUS,RP0 ; Set the body of the file register 1
The bit test is a zero jump instruction :BTFSC
【 Format 】 BTFSC F,B
【 function 】 Bit test is 0 Jump
【 explain 】
(1)BTFSC yes Bit Test,Skip if Clear Abbreviation ;
(2) test F The first of the registers B position , if F(B)=0 Then adjust to the next instruction , Otherwise, execute in sequence .
【 example 】
BTFSC PORTB,0 ; testing PORTB The second in the mouth 0 Whether a is 0? yes ! Skip the next instruction
GOTO CHECK ; no ! Then go to the label CHECK The sentence of
CALL DELAY ;PORTB Of the 0 Is it 1 Then execute the statement directly , Call delay subroutine
Bit test is 1 Jump instruction :BTFSS
【 Format 】 BTFSS F,B
【 function 】 Bit test bit 1 Jump instruction
【 explain 】
(1)BTFSS yes Bit Test F,Skip if Set Abbreviation ;
(2) test F The first of the registers B position , if F(B)=1, Then jump to the next instruction , Otherwise, execute in sequence .
【 example 】
BTFSS PORTB,0 ; testing PORTB The second in the mouth 0 Whether a is 1? yes ! Skip the next instruction
GOTO CHECK ; no ! Then go to the label CHECK The sentence of
CALL DELAY ;PORTB Of the 0 Is it 1 Then execute the sentence directly , Call delay subroutine
Constant transfer instruction :MOVLW
【 Format 】 MOVLW K
【 function 】 Constant transfer
【 explain 】(1)MOVLW yes Move literal to W Abbreviation ;
(2) take 8 Bit immediate is transferred to W register ,k It's a constant 、 Immediate number and label ;
(3) Does not affect the status bit
【 example 】
MOVLW 0x1E ; constant 30 send W
Subroutine call instruction :CALL
【 Format 】 CALL K
【 function 】 Subroutine call
【 explain 】
(1)CALL yes CALL subroutine Abbreviation ;
(2)K Is the immediate address ;
(3) Does not affect the status bit .
【 example 】
CALL DELAY ; Call delay subroutine
DELAY …… ; Delay subroutine DELAY
……
RETURN
An unconditional jump order :GOTO
【 Format 】 GOTO K
【 function 】 Jump unconditionally
【 explain 】
(1)GOTO yes Go to address Abbreviation ;
(2) Directive K, It is often associated with the label in the program ;
(3) Does not affect the status bit .
【 example 】
STOP GOTO STOP ; Loop execution GOTO sentence , So as to stop
Subroutines return instructions :RETURN
【 Format 】 RETURN
【 function 】 Subprogram return
【 explain 】
(1)RETURN yes Return from Subroutine Abbreviation ;
(2) Pop up the contents of the cell at the top of the stack and send them to PC, So as to return to the breakpoint of the main program ;
(3) Does not affect the status bit .
【 example 】
SUB MOVLW 01H ; Subroutines
……
RETURN ; Subprogram return
Empty operation instruction :NOP
【 Format 】 NOP
【 function 】 Empty operation
【 explain 】
(1)NOP yes No Operation Abbreviation ;
(2) No action generated , Only make PC Add 1, Consume an instruction cycle NOP;
(3) Does not affect the status bit .
【 example 】
MOVLW 0xOF ; send OFH To W
MOVWF PORTB ;W Content write B mouth
NOP ; Empty operation
MOVF PORTB,W ; Read operations
Examples of commonly used pseudo instructions
Symbolic name assignment pseudo instruction :EQU
【 Format 】 Symbol name EQU nn
【 function 】 Symbol name assignment
【 explain 】
(1) Assign a value to a symbol name or register , Once the symbol name is set by EQU assignment , Its value cannot be redefined ;
(2)nn Is a binary value with different length .
【 example 】
COUNT EQU 100 ; Definition COUNT Constant 100
Program start address pseudo instruction :ORG
【 Format 】 ORG nnnn
【 function 】 Program start address
【 explain 】
(1) Used to specify the starting address of the source program after the pseudo instruction , That is, the first address of the assembled machine code object program stored in the program memory of the single chip microcomputer ;
(2)nnnn It's a 13 Is a long address parameter .
【 example 】
ORG 0x00 ; The program assembly address is from 00H Start
Program end pseudo instruction :END
【 Format 】 END
【 function 】 Program end
【 explain 】
(1) Pseudo instruction at the end of instruction END Is the notification assembler MPASM End the assembly of the source program , Even if there are statements after , And no longer compile ;
(2) In a source program, there must be END Pseudo instruction ;
(3) There can only be one END;
(4) At the end of the whole program .
【 example 】 Use directly at the end of the program , This ends the program
Call in external function pseudo instruction :INCLUDE
【 Format 】 INCLUDE “ file name ”
【 function 】 Call in external functions
【 explain 】
(1) Used to tell the assembler , Include a pre compiled external program file , As part of this source program ;
(2) This can reduce repetitive work , Improve programming efficiency .
————————————————
Copyright notice : This paper is about CSDN Blogger 「「 Cancelled 」」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/weixin_43014927/article/details/104422099
边栏推荐
- 嵌入式c语言开发之宏定义求两个数的最大值的使用技巧
- (2022牛客多校二)K-Link with Bracket Sequence I(动态规划)
- Baidu, Alibaba, Tencent, who fell first?
- R奇怪语法总结
- In depth analysis: is the hottest business model in 2022 linked by 2+1 a legal model?
- Sword finger offer 36. binary search tree and bidirectional linked list
- Binary search tree (day 75)
- Sword finger offer 54. the k-th node of the binary search tree
- Vbs script COM object extension and use (3)
- U-boot-1.1.6 transplant notes (beginner)
猜你喜欢
![[ultra detailed diagram] FPN + mask RCNN](/img/ef/ddd62fe7e54074c134aa5ee4cc5840.png)
[ultra detailed diagram] FPN + mask RCNN

JTAG debugging source level debugging of arm bare board debugging

EOL offline sequence based on iso13209 (Otx)

It is said that screentogif is a GIF recording artifact, but I don't know that its strength is far from here

Blocking Queue Analysis

Netease game Flink SQL platform practice

Xiaomi 12s UTRA Leica watermark generation online tool

【datawhale202207】强化学习:策略梯度和近端策略优化

NFT: how to improve rentable NFT (erc-4907)

R奇怪语法总结
随机推荐
Date (day 76)
Jstat command summary [easy to understand]
Cout format output common functions and flags summary
Ceres solver version 1.14 and eigen3.2.9
“font/woff“ and “font/woff2“ in file “mime.types“
The code spell checker plug-in avoids some specific vocabulary errors "XXX": unknown word.cspell
[datawhale202207] reinforcement learning: the foundation of reinforcement learning
Temperature table lookup and calculation formula
[ultra detailed diagram] FPN + mask RCNN
NFT: how to improve rentable NFT (erc-4907)
JTAG debugging source level debugging of arm bare board debugging
Keilc51 usage details (III)
Classic cases of static keywords and block blocks
(15) [driver development] over written copy
VBA common objects
机器学习 Keras拟合正弦函数
Data too long for column ‘data‘ at row 1以及设置成longblob造成的乱码解决。node-mysql
Case ---- how efficient is the buffer stream compared with the ordinary input stream and output stream?
How to troubleshoot the problem of too many inodes
【Node】服务端口被占用Error: listen EADDRINUSE: address already in use :::9000-如何关闭node启动的端口