Escolar Documentos
Profissional Documentos
Cultura Documentos
Disciplina: Microcontroladores
Prof. Remy Eskinazi, MSc
Modos de endereçamento 8051 (1)
• Registrador – (Rn)
MOV R1,A ; R1 Acc
MOV B,R3 ;B R3
2
Microcontroladores - Prof. Remy Eskinazi
Modos de endereçamento 8051 (2)
• Indireto por Registrador - @R0, @R1, @DPTR
3
Microcontroladores - Prof. Remy Eskinazi
Modos de endereçamento 8051 (3)
Exemplos:
Salto Incodicional:
JMP (Address16)
AJMP (Address11)
SJMP (Address8)
LJMP (Address16)
Salto condicional:
JC (Address8)
JNC (Address8)
JB (Address8)
JNB (Address8)
4
Microcontroladores - Prof. Remy Eskinazi
Exemplo de Programa Assembly
org 0h ;Reset
sjmp inicio
5
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051
• Tipos de instruções
– Movimentação de Dados
– Aritméticas
– Lógicas
– Manipulação de Bit
– Controle de programa (Saltos e Desvios)
6
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Movimentação de Dados
MOVE
MOV A, #n A Immediate
Direct A Direct
R A Register
@Ri A Register Indirect
Add/Subtract
ADD A, # Acc A+Immediate
D
R
@R
Inc/Dec
INC A Acc Acc+1
D
R
@R
DPTR
• DEC A Acc Acc-1
D
R
@R
Mul/Div
MUL AB B:A Acc * B (unsigned)
DIV AB A Quo ( A/B ) (unsigned)
B Rem( A/B )
10
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Lógicas
AND,OR,XOR
AND A, #
ORL D
XRL R
@R
D, A
D, #
• Outras
CLR A Acc 0
CPL A Acc Acc
SWAP A Acc(7-4) Acc(3-0)
11
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Lógicas
Rotações 7 0
RL A Acc
7 0
RLC A C Acc
7 0
RR A Acc
7 0
Acc C
RRC A
12
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Manipulação de Bits
Clear/Set/Complement
CLR C Carry 0
bit bit 0
SETB C
bit
CPL C
bit
And, Or, Move
ANL C, bit Carry Carry AND bit
C, /bit Carry Carry AND bit
ORL C, bit
C, /bit
MOV C, bit
bit, C
13
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Manipulação de Bits
Saltos
JC label Jump if Carry set
JNC label Jump if Carry clear
JB bit, label Jump if bit set
JNB bit, label Jump if bit clear
JBC bit, label Jump if bit set, then clear bit
14
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Controle do Programa
Saltos
AJMP label-A Absolute Jump- 11 bits(2K)
LJMP label-L Long Jump - 16 bits (64K)
SJMP label Short Jump
JMP @A+DPTR Jump Indirect PC (A+DPTR)
JZ label Jump if zero
JNZ label Jump if not zero
Compara e Salta
CJNE A, #, label Compare 1st op to 2nd op and
A, D, label jump to label if not Equal
R, #, label
@R,#, label
15
Microcontroladores - Prof. Remy Eskinazi
Instruções 8051 – Controle do Programa
Decrementa e Salta
DJNZ R, label Rn = Rn-1 , Jump if not zero
D, label
16
Microcontroladores - Prof. Remy Eskinazi
Programa Acha Zero – Algoritmo
INÍCIO
se em um range de
memória existe um A=0 ?
S F0 1
byte 0 N
DPTR DPTR+1
N
FIM?
RET
17
Microcontroladores - Prof. Remy Eskinazi
Programa Acha Zero – Código Fonte
18
Microcontroladores - Prof. Remy Eskinazi
INICIO
Subrotina
Acc <-- (Ponteiro) AchaMaior
(Acc <-- ( DPTR ))
Próxima posição
(DPTR <-- DPTR + 1)
N
DPh = 01H ?
Acc <-- B
DPTR <-- R1R0
19
RET
Microcontroladores - Prof. Remy Eskinazi